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
67f5ac36
Commit
67f5ac36
authored
Jan 19, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: implement subscript and superscript renderer
parent
7236552b
Changes
7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
417 additions
and
161 deletions
+417
-161
markdown_service.go
api/v2/markdown_service.go
+8
-0
markdown_service.proto
proto/api/v2/markdown_service.proto
+12
-0
README.md
proto/gen/api/v2/README.md
+36
-0
markdown_service.pb.go
proto/gen/api/v2/markdown_service.pb.go
+335
-161
Renderer.tsx
web/src/components/MemoContent/Renderer.tsx
+8
-0
Subscript.tsx
web/src/components/MemoContent/Subscript.tsx
+9
-0
Superscript.tsx
web/src/components/MemoContent/Superscript.tsx
+9
-0
No files found.
api/v2/markdown_service.go
View file @
67f5ac36
...
@@ -92,6 +92,10 @@ func convertFromASTNode(rawNode ast.Node) *apiv2pb.Node {
...
@@ -92,6 +92,10 @@ func convertFromASTNode(rawNode ast.Node) *apiv2pb.Node {
node
.
Node
=
&
apiv2pb
.
Node_MathNode
{
MathNode
:
&
apiv2pb
.
MathNode
{
Content
:
n
.
Content
}}
node
.
Node
=
&
apiv2pb
.
Node_MathNode
{
MathNode
:
&
apiv2pb
.
MathNode
{
Content
:
n
.
Content
}}
case
*
ast
.
Highlight
:
case
*
ast
.
Highlight
:
node
.
Node
=
&
apiv2pb
.
Node_HighlightNode
{
HighlightNode
:
&
apiv2pb
.
HighlightNode
{
Content
:
n
.
Content
}}
node
.
Node
=
&
apiv2pb
.
Node_HighlightNode
{
HighlightNode
:
&
apiv2pb
.
HighlightNode
{
Content
:
n
.
Content
}}
case
*
ast
.
Subscript
:
node
.
Node
=
&
apiv2pb
.
Node_SubscriptNode
{
SubscriptNode
:
&
apiv2pb
.
SubscriptNode
{
Content
:
n
.
Content
}}
case
*
ast
.
Superscript
:
node
.
Node
=
&
apiv2pb
.
Node_SuperscriptNode
{
SuperscriptNode
:
&
apiv2pb
.
SuperscriptNode
{
Content
:
n
.
Content
}}
default
:
default
:
node
.
Node
=
&
apiv2pb
.
Node_TextNode
{
TextNode
:
&
apiv2pb
.
TextNode
{}}
node
.
Node
=
&
apiv2pb
.
Node_TextNode
{
TextNode
:
&
apiv2pb
.
TextNode
{}}
}
}
...
@@ -165,6 +169,10 @@ func convertToASTNode(node *apiv2pb.Node) ast.Node {
...
@@ -165,6 +169,10 @@ func convertToASTNode(node *apiv2pb.Node) ast.Node {
return
&
ast
.
Math
{
Content
:
n
.
MathNode
.
Content
}
return
&
ast
.
Math
{
Content
:
n
.
MathNode
.
Content
}
case
*
apiv2pb
.
Node_HighlightNode
:
case
*
apiv2pb
.
Node_HighlightNode
:
return
&
ast
.
Highlight
{
Content
:
n
.
HighlightNode
.
Content
}
return
&
ast
.
Highlight
{
Content
:
n
.
HighlightNode
.
Content
}
case
*
apiv2pb
.
Node_SubscriptNode
:
return
&
ast
.
Subscript
{
Content
:
n
.
SubscriptNode
.
Content
}
case
*
apiv2pb
.
Node_SuperscriptNode
:
return
&
ast
.
Superscript
{
Content
:
n
.
SuperscriptNode
.
Content
}
default
:
default
:
return
&
ast
.
Text
{}
return
&
ast
.
Text
{}
}
}
...
...
proto/api/v2/markdown_service.proto
View file @
67f5ac36
...
@@ -49,6 +49,8 @@ enum NodeType {
...
@@ -49,6 +49,8 @@ enum NodeType {
ESCAPING_CHARACTER
=
22
;
ESCAPING_CHARACTER
=
22
;
MATH
=
23
;
MATH
=
23
;
HIGHLIGHT
=
24
;
HIGHLIGHT
=
24
;
SUBSCRIPT
=
25
;
SUPERSCRIPT
=
26
;
}
}
message
Node
{
message
Node
{
...
@@ -78,6 +80,8 @@ message Node {
...
@@ -78,6 +80,8 @@ message Node {
EscapingCharacterNode
escaping_character_node
=
23
;
EscapingCharacterNode
escaping_character_node
=
23
;
MathNode
math_node
=
24
;
MathNode
math_node
=
24
;
HighlightNode
highlight_node
=
25
;
HighlightNode
highlight_node
=
25
;
SubscriptNode
subscript_node
=
26
;
SuperscriptNode
superscript_node
=
27
;
}
}
}
}
...
@@ -195,3 +199,11 @@ message MathNode {
...
@@ -195,3 +199,11 @@ message MathNode {
message
HighlightNode
{
message
HighlightNode
{
string
content
=
1
;
string
content
=
1
;
}
}
message
SubscriptNode
{
string
content
=
1
;
}
message
SuperscriptNode
{
string
content
=
1
;
}
proto/gen/api/v2/README.md
View file @
67f5ac36
...
@@ -88,6 +88,8 @@
...
@@ -88,6 +88,8 @@
-
[
ParseMarkdownRequest
](
#memos-api-v2-ParseMarkdownRequest
)
-
[
ParseMarkdownRequest
](
#memos-api-v2-ParseMarkdownRequest
)
-
[
ParseMarkdownResponse
](
#memos-api-v2-ParseMarkdownResponse
)
-
[
ParseMarkdownResponse
](
#memos-api-v2-ParseMarkdownResponse
)
-
[
StrikethroughNode
](
#memos-api-v2-StrikethroughNode
)
-
[
StrikethroughNode
](
#memos-api-v2-StrikethroughNode
)
-
[
SubscriptNode
](
#memos-api-v2-SubscriptNode
)
-
[
SuperscriptNode
](
#memos-api-v2-SuperscriptNode
)
-
[
TableNode
](
#memos-api-v2-TableNode
)
-
[
TableNode
](
#memos-api-v2-TableNode
)
-
[
TableNode.Row
](
#memos-api-v2-TableNode-Row
)
-
[
TableNode.Row
](
#memos-api-v2-TableNode-Row
)
-
[
TagNode
](
#memos-api-v2-TagNode
)
-
[
TagNode
](
#memos-api-v2-TagNode
)
...
@@ -1238,6 +1240,8 @@
...
@@ -1238,6 +1240,8 @@
| escaping_character_node |
[
EscapingCharacterNode
](
#memos-api-v2-EscapingCharacterNode
)
| | |
| escaping_character_node |
[
EscapingCharacterNode
](
#memos-api-v2-EscapingCharacterNode
)
| | |
| math_node |
[
MathNode
](
#memos-api-v2-MathNode
)
| | |
| math_node |
[
MathNode
](
#memos-api-v2-MathNode
)
| | |
| highlight_node |
[
HighlightNode
](
#memos-api-v2-HighlightNode
)
| | |
| highlight_node |
[
HighlightNode
](
#memos-api-v2-HighlightNode
)
| | |
| subscript_node |
[
SubscriptNode
](
#memos-api-v2-SubscriptNode
)
| | |
| superscript_node |
[
SuperscriptNode
](
#memos-api-v2-SuperscriptNode
)
| | |
...
@@ -1321,6 +1325,36 @@
...
@@ -1321,6 +1325,36 @@
<a
name=
"memos-api-v2-SubscriptNode"
></a>
### SubscriptNode
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| content |
[
string
](
#string
)
| | |
<a
name=
"memos-api-v2-SuperscriptNode"
></a>
### SuperscriptNode
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| content |
[
string
](
#string
)
| | |
<a
name=
"memos-api-v2-TableNode"
></a>
<a
name=
"memos-api-v2-TableNode"
></a>
### TableNode
### TableNode
...
@@ -1452,6 +1486,8 @@
...
@@ -1452,6 +1486,8 @@
| ESCAPING_CHARACTER | 22 | |
| ESCAPING_CHARACTER | 22 | |
| MATH | 23 | |
| MATH | 23 | |
| HIGHLIGHT | 24 | |
| HIGHLIGHT | 24 | |
| SUBSCRIPT | 25 | |
| SUPERSCRIPT | 26 | |
...
...
proto/gen/api/v2/markdown_service.pb.go
View file @
67f5ac36
This diff is collapsed.
Click to expand it.
web/src/components/MemoContent/Renderer.tsx
View file @
67f5ac36
...
@@ -18,6 +18,8 @@ import {
...
@@ -18,6 +18,8 @@ import {
OrderedListNode
,
OrderedListNode
,
ParagraphNode
,
ParagraphNode
,
StrikethroughNode
,
StrikethroughNode
,
SubscriptNode
,
SuperscriptNode
,
TableNode
,
TableNode
,
TagNode
,
TagNode
,
TaskListNode
,
TaskListNode
,
...
@@ -41,6 +43,8 @@ import Math from "./Math";
...
@@ -41,6 +43,8 @@ import Math from "./Math";
import
OrderedList
from
"./OrderedList"
;
import
OrderedList
from
"./OrderedList"
;
import
Paragraph
from
"./Paragraph"
;
import
Paragraph
from
"./Paragraph"
;
import
Strikethrough
from
"./Strikethrough"
;
import
Strikethrough
from
"./Strikethrough"
;
import
Subscript
from
"./Subscript"
;
import
Superscript
from
"./Superscript"
;
import
Table
from
"./Table"
;
import
Table
from
"./Table"
;
import
Tag
from
"./Tag"
;
import
Tag
from
"./Tag"
;
import
TaskList
from
"./TaskList"
;
import
TaskList
from
"./TaskList"
;
...
@@ -102,6 +106,10 @@ const Renderer: React.FC<Props> = ({ index, node }: Props) => {
...
@@ -102,6 +106,10 @@ const Renderer: React.FC<Props> = ({ index, node }: Props) => {
return
<
Highlight
{
...
(
node
.
highlightNode
as
HighlightNode
)}
/>;
return
<
Highlight
{
...
(
node
.
highlightNode
as
HighlightNode
)}
/>;
case
NodeType
.
ESCAPING_CHARACTER
:
case
NodeType
.
ESCAPING_CHARACTER
:
return
<
EscapingCharacter
{
...
(
node
.
escapingCharacterNode
as
EscapingCharacterNode
)}
/>;
return
<
EscapingCharacter
{
...
(
node
.
escapingCharacterNode
as
EscapingCharacterNode
)}
/>;
case
NodeType
.
SUBSCRIPT
:
return
<
Subscript
{
...
(
node
.
subscriptNode
as
SubscriptNode
)}
/>;
case
NodeType
.
SUPERSCRIPT
:
return
<
Superscript
{
...
(
node
.
superscriptNode
as
SuperscriptNode
)}
/>;
default
:
default
:
return
null
;
return
null
;
}
}
...
...
web/src/components/MemoContent/Subscript.tsx
0 → 100644
View file @
67f5ac36
interface
Props
{
content
:
string
;
}
const
Subscript
:
React
.
FC
<
Props
>
=
({
content
}:
Props
)
=>
{
return
<
sub
>
{
content
}
</
sub
>;
};
export
default
Subscript
;
web/src/components/MemoContent/Superscript.tsx
0 → 100644
View file @
67f5ac36
interface
Props
{
content
:
string
;
}
const
Superscript
:
React
.
FC
<
Props
>
=
({
content
}:
Props
)
=>
{
return
<
sup
>
{
content
}
</
sup
>;
};
export
default
Superscript
;
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