Skip to content

Commit

Permalink
rspress: component: fix
Browse files Browse the repository at this point in the history
ajasma committed Dec 20, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 5d4594d commit e6f02a8
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions embedded/rspress/src/components/List.tsx
Original file line number Diff line number Diff line change
@@ -34,6 +34,7 @@ interface ListItemProps {

const ListItem: React.FC<ListItemProps> = ({ item, depth = 0 }) => {
const { props, content, children } = item;


const containerClasses = [
getColorClass(props.textColor),
@@ -93,8 +94,17 @@ const ListItem: React.FC<ListItemProps> = ({ item, depth = 0 }) => {

// lets simplify and show only content
return (
<li>
{content.map((segment, index) => renderTextSegment(segment, index))}
<li className={containerClasses}>
<div>
{content.map((segment, index) => renderTextSegment(segment, index))}
</div>
{children.length > 0 && (
<ul className={item.type === 'numberedListItem' ? 'kal-list-decimal kal-ml-4 kal-mb-2' : 'kal-list-disc kal-ml-4 kal-mb-2'}>
{children.map((child) => (
<ListItem key={child.id} item={child} depth={depth + 1} />
))}
</ul>
)}
</li>
)
};
@@ -111,9 +121,12 @@ export const List: React.FC<ListProps> = ({ rawJson }) => {

for (let i = 0; i < rawJson.length; i++) {
if (rawJson[i].type === "numberedListItem") {
console.log('row number list ', rawJson[i]);

type = "kal-list-decimal";
break;
} else if (rawJson[i].type === "bulletListItem") {
console.log('row Bullet list ', rawJson[i]);
type = "kal-list-disc";
break;
}
@@ -122,6 +135,8 @@ export const List: React.FC<ListProps> = ({ rawJson }) => {
if (type === "") return null;

if (type === "kal-list-disc") {
console.log('kal-list-disc');

return (
<ul className="kal-list-disc">
{rawJson.map((item) => (

0 comments on commit e6f02a8

Please sign in to comment.