From fa01a6210f12fe9987faba622a7ef49315fed9cc Mon Sep 17 00:00:00 2001 From: phattran2905 Date: Fri, 13 Sep 2024 15:20:51 -0700 Subject: [PATCH 1/2] fix(core): reset list count for sub-list items --- .../form/inputs/PortableText/Editor.styles.tsx | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx b/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx index ccf1d036b2c..1ccfd31cca6 100644 --- a/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx +++ b/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx @@ -95,26 +95,23 @@ export const EditableWrapper = styled(Card)<{$isFullscreen: boolean; $readOnly?: & > .pt-list-item-bullet + .pt-list-item-number, & > .pt-list-item-number + .pt-list-item-bullet { margin-top: ${({theme}) => theme.sanity.space[3]}px; - counter-reset: ${TEXT_LEVELS.map((l) => createListName(l)).join(' ')}; } & > :not(.pt-list-item) + .pt-list-item { margin-top: ${({theme}) => theme.sanity.space[2]}px; } - /* Reset the list count if the element is not a numbered list item */ + /* Reset the list count all the sub-list items */ + & > .pt-list-item-number.pt-list-item-level-${TEXT_LEVELS[0]} { + counter-set: ${TEXT_LEVELS.slice(1) + .map((l) => createListName(l)) + .join(' ')}; + } + & > :not(.pt-list-item-number) { counter-set: ${TEXT_LEVELS.map((l) => createListName(l)).join(' ')}; } - ${TEXT_LEVELS.slice(1).map((l) => { - return css` - & > .pt-list-item-level-${l} + .pt-list-item-level-${l - 1} { - counter-reset: ${createListName(l)}; - } - ` - })} - & > .pt-list-item + :not(.pt-list-item) { margin-top: ${({theme}) => theme.sanity.space[3]}px; } From eb51fea1e0c2f112559f1c21fb5154ef6927b5e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Hamburger=20Gr=C3=B8ngaard?= Date: Mon, 16 Sep 2024 09:06:49 +0200 Subject: [PATCH 2/2] fixup! fix(core): reset list count for sub-list items --- .../src/core/form/inputs/PortableText/Editor.styles.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx b/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx index 1ccfd31cca6..458399b72ed 100644 --- a/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx +++ b/packages/sanity/src/core/form/inputs/PortableText/Editor.styles.tsx @@ -101,6 +101,11 @@ export const EditableWrapper = styled(Card)<{$isFullscreen: boolean; $readOnly?: margin-top: ${({theme}) => theme.sanity.space[2]}px; } + /* Reset the list count if the element is not a numbered list item */ + & > :not(.pt-list-item-number) { + counter-set: ${TEXT_LEVELS.map((l) => createListName(l)).join(' ')}; + } + /* Reset the list count all the sub-list items */ & > .pt-list-item-number.pt-list-item-level-${TEXT_LEVELS[0]} { counter-set: ${TEXT_LEVELS.slice(1) @@ -108,10 +113,6 @@ export const EditableWrapper = styled(Card)<{$isFullscreen: boolean; $readOnly?: .join(' ')}; } - & > :not(.pt-list-item-number) { - counter-set: ${TEXT_LEVELS.map((l) => createListName(l)).join(' ')}; - } - & > .pt-list-item + :not(.pt-list-item) { margin-top: ${({theme}) => theme.sanity.space[3]}px; }