Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
41d9c9d7
Commit
41d9c9d7
authored
Dec 25, 2024
by
johnnyjoy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: order list starts
parent
e913271f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
2 deletions
+16
-2
List.tsx
web/src/components/MemoContent/List.tsx
+16
-2
No files found.
web/src/components/MemoContent/List.tsx
View file @
41d9c9d7
import
clsx
from
"clsx"
;
import
clsx
from
"clsx"
;
import
{
head
}
from
"lodash-es"
;
import
React
from
"react"
;
import
React
from
"react"
;
import
{
ListNode_Kind
,
Node
,
NodeType
}
from
"@/types/proto/api/v1/markdown_service"
;
import
{
ListNode_Kind
,
Node
,
NodeType
}
from
"@/types/proto/api/v1/markdown_service"
;
import
Renderer
from
"./Renderer"
;
import
Renderer
from
"./Renderer"
;
...
@@ -14,7 +15,7 @@ const List: React.FC<Props> = ({ kind, indent, children }: Props) => {
...
@@ -14,7 +15,7 @@ const List: React.FC<Props> = ({ kind, indent, children }: Props) => {
let
prevNode
:
Node
|
null
=
null
;
let
prevNode
:
Node
|
null
=
null
;
let
skipNextLineBreakFlag
=
false
;
let
skipNextLineBreakFlag
=
false
;
const
getListContainer
=
(
kind
:
ListNode_Kind
)
=>
{
const
getListContainer
=
()
=>
{
switch
(
kind
)
{
switch
(
kind
)
{
case
ListNode_Kind
.
ORDERED
:
case
ListNode_Kind
.
ORDERED
:
return
"ol"
;
return
"ol"
;
...
@@ -27,13 +28,26 @@ const List: React.FC<Props> = ({ kind, indent, children }: Props) => {
...
@@ -27,13 +28,26 @@ const List: React.FC<Props> = ({ kind, indent, children }: Props) => {
}
}
};
};
const
getAttributes
=
()
=>
{
if
(
kind
===
ListNode_Kind
.
ORDERED
)
{
const
firstChild
=
head
(
children
);
if
(
firstChild
?.
type
===
NodeType
.
ORDERED_LIST_ITEM
)
{
return
{
start
:
firstChild
.
orderedListItemNode
?.
number
,
};
}
}
return
{};
};
return
React
.
createElement
(
return
React
.
createElement
(
getListContainer
(
kind
),
getListContainer
(),
{
{
className
:
clsx
(
className
:
clsx
(
`list-inside
${
kind
===
ListNode_Kind
.
ORDERED
?
"list-decimal"
:
kind
===
ListNode_Kind
.
UNORDERED
?
"list-disc"
:
"list-none"
}
`
,
`list-inside
${
kind
===
ListNode_Kind
.
ORDERED
?
"list-decimal"
:
kind
===
ListNode_Kind
.
UNORDERED
?
"list-disc"
:
"list-none"
}
`
,
indent
>
0
?
`pl-
${
2
*
indent
}
`
:
""
,
indent
>
0
?
`pl-
${
2
*
indent
}
`
:
""
,
),
),
...
getAttributes
(),
},
},
children
.
map
((
child
,
index
)
=>
{
children
.
map
((
child
,
index
)
=>
{
if
(
prevNode
?.
type
!==
NodeType
.
LINE_BREAK
&&
child
.
type
===
NodeType
.
LINE_BREAK
&&
skipNextLineBreakFlag
)
{
if
(
prevNode
?.
type
!==
NodeType
.
LINE_BREAK
&&
child
.
type
===
NodeType
.
LINE_BREAK
&&
skipNextLineBreakFlag
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment