mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-01 17:50:50 +08:00
fix(core): nested numbered list order (#14764)
## The Fix ## Fixes #13396. The issue happened because 'doc.getPrev(model)' returns previous node based in document order instead of previous sibling within list level. This caused nested list items to inherit the numbering from their parent rather than restarting. The fix ensures that numbering is calculated relative to correct list context. ## Video Demonstration ## ### Before ### https://github.com/user-attachments/assets/9523209a-93d9-4984-aa9e-149ac1941036 ### After ### https://github.com/user-attachments/assets/ff28b166-3572-4536-9893-0ab5c05c8d9f <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Enhanced numbered list ordering logic for improved list handling. * **Chores** * Updated environment configuration template with active sample values for database connectivity, caching services, AI integrations, and email delivery settings. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -30,7 +30,11 @@ export function correctNumberedListsOrderToPrev(
|
||||
|
||||
const fn = () => {
|
||||
// step 1
|
||||
const previousSibling = doc.getPrev(model);
|
||||
const parent = doc.getParent(model);
|
||||
if (!parent) return;
|
||||
const index = parent.children.indexOf(model);
|
||||
const previousSibling = index > 0 ? parent.children[index - 1] : null;
|
||||
|
||||
if (
|
||||
previousSibling &&
|
||||
matchModels(previousSibling, [ListBlockModel]) &&
|
||||
|
||||
Reference in New Issue
Block a user