Skip to content

Commit 0027712

Browse files
committed
feat: ol start attribute consideration
1 parent dc9d615 commit 0027712

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/web/pmPlugins/OrderedListMarkerWidthPlugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export const OrderedListMarkerWidthPlugin = Extension.create({
2020
return true;
2121
}
2222

23-
const maxNumber = Math.max(0, node.childCount);
23+
const start =
24+
typeof node.attrs.start === 'number' ? node.attrs.start : 1;
25+
const maxNumber = start + Math.max(0, node.childCount - 1);
2426
const digits = String(maxNumber).length;
2527

2628
decorations.push(

src/web/useOrderedListMarkerWidth.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ export function useOrderedListMarkerWidth(
1111
if (!root) return;
1212

1313
root.querySelectorAll('ol').forEach((ol) => {
14-
const maxNumber = Math.max(0, ol.children.length);
14+
const startAttr = Number(ol.getAttribute('start'));
15+
const start = Number.isFinite(startAttr) && startAttr > 0 ? startAttr : 1;
16+
const maxNumber = start + Math.max(0, ol.children.length - 1);
1517
ol.style.setProperty('--et-ol-digits', String(String(maxNumber).length));
1618
});
1719
}, [containerRef, finalHtml]);

0 commit comments

Comments
 (0)