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
f563b58a
Commit
f563b58a
authored
Jan 05, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix renderer props
parent
ce2d37b9
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
34 additions
and
20 deletions
+34
-20
Blockquote.tsx
web/src/components/MemoContent/Blockquote.tsx
+3
-2
Bold.tsx
web/src/components/MemoContent/Bold.tsx
+1
-1
CodeBlock.tsx
web/src/components/MemoContent/CodeBlock.tsx
+2
-1
Heading.tsx
web/src/components/MemoContent/Heading.tsx
+3
-2
HorizontalRule.tsx
web/src/components/MemoContent/HorizontalRule.tsx
+3
-1
LineBreak.tsx
web/src/components/MemoContent/LineBreak.tsx
+3
-1
OrderedList.tsx
web/src/components/MemoContent/OrderedList.tsx
+3
-2
Paragraph.tsx
web/src/components/MemoContent/Paragraph.tsx
+3
-2
Renderer.tsx
web/src/components/MemoContent/Renderer.tsx
+7
-7
UnorderedList.tsx
web/src/components/MemoContent/UnorderedList.tsx
+1
-1
index.ts
web/src/components/MemoContent/types/index.ts
+5
-0
No files found.
web/src/components/MemoContent/Blockquote.tsx
View file @
f563b58a
import
{
Node
}
from
"@/types/proto/api/v2/markdown_service"
;
import
Renderer
from
"./Renderer"
;
import
{
BaseProps
}
from
"./types"
;
interface
Props
{
interface
Props
extends
BaseProps
{
children
:
Node
[];
}
...
...
@@ -9,7 +10,7 @@ const Blockquote: React.FC<Props> = ({ children }: Props) => {
return
(
<
blockquote
>
{
children
.
map
((
child
,
index
)
=>
(
<
Renderer
key=
{
`${child.type}-${index}`
}
node=
{
child
}
/>
<
Renderer
key=
{
`${child.type}-${index}`
}
index=
{
String
(
index
)
}
node=
{
child
}
/>
))
}
</
blockquote
>
);
...
...
web/src/components/MemoContent/Bold.tsx
View file @
f563b58a
...
...
@@ -10,7 +10,7 @@ const Bold: React.FC<Props> = ({ children }: Props) => {
return
(
<
strong
>
{
children
.
map
((
child
,
index
)
=>
(
<
Renderer
key=
{
`${child.type}-${index}`
}
node=
{
child
}
/>
<
Renderer
key=
{
`${child.type}-${index}`
}
index=
{
String
(
index
)
}
node=
{
child
}
/>
))
}
</
strong
>
);
...
...
web/src/components/MemoContent/CodeBlock.tsx
View file @
f563b58a
...
...
@@ -4,8 +4,9 @@ import copy from "copy-to-clipboard";
import
hljs
from
"highlight.js"
;
import
toast
from
"react-hot-toast"
;
import
Icon
from
"../Icon"
;
import
{
BaseProps
}
from
"./types"
;
interface
Props
{
interface
Props
extends
BaseProps
{
language
:
string
;
content
:
string
;
}
...
...
web/src/components/MemoContent/Heading.tsx
View file @
f563b58a
import
{
Node
}
from
"@/types/proto/api/v2/markdown_service"
;
import
Renderer
from
"./Renderer"
;
import
{
BaseProps
}
from
"./types"
;
interface
Props
{
interface
Props
extends
BaseProps
{
level
:
number
;
children
:
Node
[];
}
...
...
@@ -24,7 +25,7 @@ const Heading: React.FC<Props> = ({ level, children }: Props) => {
return
(
<
Head
className=
{
className
}
>
{
children
.
map
((
child
,
index
)
=>
(
<
Renderer
key=
{
`${child.type}-${index}`
}
node=
{
child
}
/>
<
Renderer
key=
{
`${child.type}-${index}`
}
index=
{
String
(
index
)
}
node=
{
child
}
/>
))
}
</
Head
>
);
...
...
web/src/components/MemoContent/HorizontalRule.tsx
View file @
f563b58a
interface
Props
{
import
{
BaseProps
}
from
"./types"
;
interface
Props
extends
BaseProps
{
symbol
:
string
;
}
...
...
web/src/components/MemoContent/LineBreak.tsx
View file @
f563b58a
interface
Props
{}
import
{
BaseProps
}
from
"./types"
;
interface
Props
extends
BaseProps
{}
const
LineBreak
:
React
.
FC
<
Props
>
=
()
=>
{
return
<
br
/>;
...
...
web/src/components/MemoContent/OrderedList.tsx
View file @
f563b58a
import
{
Node
}
from
"@/types/proto/api/v2/markdown_service"
;
import
Renderer
from
"./Renderer"
;
import
{
BaseProps
}
from
"./types"
;
interface
Props
{
interface
Props
extends
BaseProps
{
number
:
string
;
children
:
Node
[];
}
...
...
@@ -15,7 +16,7 @@ const OrderedList: React.FC<Props> = ({ number, children }: Props) => {
</
div
>
<
div
>
{
children
.
map
((
child
,
index
)
=>
(
<
Renderer
key=
{
`${child.type}-${index}`
}
node=
{
child
}
/>
<
Renderer
key=
{
`${child.type}-${index}`
}
index=
{
String
(
index
)
}
node=
{
child
}
/>
))
}
</
div
>
</
li
>
...
...
web/src/components/MemoContent/Paragraph.tsx
View file @
f563b58a
import
{
Node
}
from
"@/types/proto/api/v2/markdown_service"
;
import
Renderer
from
"./Renderer"
;
import
{
BaseProps
}
from
"./types"
;
interface
Props
{
interface
Props
extends
BaseProps
{
children
:
Node
[];
}
...
...
@@ -9,7 +10,7 @@ const Paragraph: React.FC<Props> = ({ children }: Props) => {
return
(
<
p
>
{
children
.
map
((
child
,
index
)
=>
(
<
Renderer
key=
{
`${child.type}-${index}`
}
node=
{
child
}
/>
<
Renderer
key=
{
`${child.type}-${index}`
}
index=
{
String
(
index
)
}
node=
{
child
}
/>
))
}
</
p
>
);
...
...
web/src/components/MemoContent/Renderer.tsx
View file @
f563b58a
...
...
@@ -51,19 +51,19 @@ interface Props {
const
Renderer
:
React
.
FC
<
Props
>
=
({
index
,
node
}:
Props
)
=>
{
switch
(
node
.
type
)
{
case
NodeType
.
LINE_BREAK
:
return
<
LineBreak
/>;
return
<
LineBreak
index=
{
index
}
/>;
case
NodeType
.
PARAGRAPH
:
return
<
Paragraph
{
...
(
node
.
paragraphNode
as
ParagraphNode
)}
/>;
return
<
Paragraph
index=
{
index
}
{
...
(
node
.
paragraphNode
as
ParagraphNode
)}
/>;
case
NodeType
.
CODE_BLOCK
:
return
<
CodeBlock
{
...
(
node
.
codeBlockNode
as
CodeBlockNode
)}
/>;
return
<
CodeBlock
index=
{
index
}
{
...
(
node
.
codeBlockNode
as
CodeBlockNode
)}
/>;
case
NodeType
.
HEADING
:
return
<
Heading
{
...
(
node
.
headingNode
as
HeadingNode
)}
/>;
return
<
Heading
index=
{
index
}
{
...
(
node
.
headingNode
as
HeadingNode
)}
/>;
case
NodeType
.
HORIZONTAL_RULE
:
return
<
HorizontalRule
{
...
(
node
.
horizontalRuleNode
as
HorizontalRuleNode
)}
/>;
return
<
HorizontalRule
index=
{
index
}
{
...
(
node
.
horizontalRuleNode
as
HorizontalRuleNode
)}
/>;
case
NodeType
.
BLOCKQUOTE
:
return
<
Blockquote
{
...
(
node
.
blockquoteNode
as
BlockquoteNode
)}
/>;
return
<
Blockquote
index=
{
index
}
{
...
(
node
.
blockquoteNode
as
BlockquoteNode
)}
/>;
case
NodeType
.
ORDERED_LIST
:
return
<
OrderedList
{
...
(
node
.
orderedListNode
as
OrderedListNode
)}
/>;
return
<
OrderedList
index=
{
index
}
{
...
(
node
.
orderedListNode
as
OrderedListNode
)}
/>;
case
NodeType
.
UNORDERED_LIST
:
return
<
UnorderedList
{
...
(
node
.
unorderedListNode
as
UnorderedListNode
)}
/>;
case
NodeType
.
TASK_LIST
:
...
...
web/src/components/MemoContent/UnorderedList.tsx
View file @
f563b58a
...
...
@@ -15,7 +15,7 @@ const UnorderedList: React.FC<Props> = ({ children }: Props) => {
</
div
>
<
div
>
{
children
.
map
((
child
,
index
)
=>
(
<
Renderer
key=
{
`${child.type}-${index}`
}
node=
{
child
}
/>
<
Renderer
key=
{
`${child.type}-${index}`
}
index=
{
String
(
index
)
}
node=
{
child
}
/>
))
}
</
div
>
</
li
>
...
...
web/src/components/MemoContent/types/index.ts
View file @
f563b58a
export
*
from
"./context"
;
export
interface
BaseProps
{
index
:
string
;
className
?:
string
;
}
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