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
f374169a
Commit
f374169a
authored
Jul 13, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: implement html element renderer
parent
4ff3b89a
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
356 additions
and
210 deletions
+356
-210
apidocs.swagger.yaml
docs/apidocs.swagger.yaml
+12
-0
go.mod
go.mod
+1
-1
go.sum
go.sum
+2
-2
markdown_service.proto
proto/api/v1/markdown_service.proto
+7
-0
markdown_service.pb.go
proto/gen/api/v1/markdown_service.pb.go
+314
-207
markdown_service.go
server/router/api/v1/markdown_service.go
+4
-0
HTMLElement.tsx
web/src/components/MemoContent/HTMLElement.tsx
+12
-0
Renderer.tsx
web/src/components/MemoContent/Renderer.tsx
+4
-0
No files found.
docs/apidocs.swagger.yaml
View file @
f374169a
...
@@ -2447,6 +2447,15 @@ definitions:
...
@@ -2447,6 +2447,15 @@ definitions:
description
:
|-
description
:
|-
stats is the stats of memo creating/updating activities.
stats is the stats of memo creating/updating activities.
key is the year-month-day string. e.g. "2020-01-01".
key is the year-month-day string. e.g. "2020-01-01".
v1HTMLElementNode
:
type
:
object
properties
:
tagName
:
type
:
string
attributes
:
type
:
object
additionalProperties
:
type
:
string
v1HeadingNode
:
v1HeadingNode
:
type
:
object
type
:
object
properties
:
properties
:
...
@@ -2836,6 +2845,8 @@ definitions:
...
@@ -2836,6 +2845,8 @@ definitions:
$ref
:
'
#/definitions/v1ReferencedContentNode'
$ref
:
'
#/definitions/v1ReferencedContentNode'
spoilerNode
:
spoilerNode
:
$ref
:
'
#/definitions/v1SpoilerNode'
$ref
:
'
#/definitions/v1SpoilerNode'
htmlElementNode
:
$ref
:
'
#/definitions/v1HTMLElementNode'
v1NodeType
:
v1NodeType
:
type
:
string
type
:
string
enum
:
enum
:
...
@@ -2869,6 +2880,7 @@ definitions:
...
@@ -2869,6 +2880,7 @@ definitions:
-
SUPERSCRIPT
-
SUPERSCRIPT
-
REFERENCED_CONTENT
-
REFERENCED_CONTENT
-
SPOILER
-
SPOILER
-
HTML_ELEMENT
default
:
NODE_UNSPECIFIED
default
:
NODE_UNSPECIFIED
v1OrderedListNode
:
v1OrderedListNode
:
type
:
object
type
:
object
...
...
go.mod
View file @
f374169a
...
@@ -25,7 +25,7 @@ require (
...
@@ -25,7 +25,7 @@ require (
github.com/spf13/cobra v1.8.1
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
github.com/spf13/viper v1.19.0
github.com/stretchr/testify v1.9.0
github.com/stretchr/testify v1.9.0
github.com/usememos/gomark v0.0.0-2024071
2135956-99d0ab9b9aa1
github.com/usememos/gomark v0.0.0-2024071
3015837-e5b687d3d637
golang.org/x/crypto v0.25.0
golang.org/x/crypto v0.25.0
golang.org/x/mod v0.19.0
golang.org/x/mod v0.19.0
golang.org/x/net v0.27.0
golang.org/x/net v0.27.0
...
...
go.sum
View file @
f374169a
...
@@ -441,8 +441,8 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM
...
@@ -441,8 +441,8 @@ github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVM
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
github.com/usememos/gomark v0.0.0-2024071
2135956-99d0ab9b9aa1 h1:4LuNOC1zgAk9K8kZjTBZ/yNJR9vgQTNAQFyWxLxJp5A
=
github.com/usememos/gomark v0.0.0-2024071
3015837-e5b687d3d637 h1:DTSf/z7oXyAJXk9bYaTHnRiLlHynWJ/ate9VKJn2awc
=
github.com/usememos/gomark v0.0.0-2024071
2135956-99d0ab9b9aa1
/go.mod h1:7CZRoYFQyyljzplOTeyODFR26O+wr0BbnpTWVLGfKJA=
github.com/usememos/gomark v0.0.0-2024071
3015837-e5b687d3d637
/go.mod h1:7CZRoYFQyyljzplOTeyODFR26O+wr0BbnpTWVLGfKJA=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
...
...
proto/api/v1/markdown_service.proto
View file @
f374169a
...
@@ -84,6 +84,7 @@ enum NodeType {
...
@@ -84,6 +84,7 @@ enum NodeType {
SUPERSCRIPT
=
27
;
SUPERSCRIPT
=
27
;
REFERENCED_CONTENT
=
28
;
REFERENCED_CONTENT
=
28
;
SPOILER
=
29
;
SPOILER
=
29
;
HTML_ELEMENT
=
30
;
}
}
message
Node
{
message
Node
{
...
@@ -118,6 +119,7 @@ message Node {
...
@@ -118,6 +119,7 @@ message Node {
SuperscriptNode
superscript_node
=
28
;
SuperscriptNode
superscript_node
=
28
;
ReferencedContentNode
referenced_content_node
=
29
;
ReferencedContentNode
referenced_content_node
=
29
;
SpoilerNode
spoiler_node
=
30
;
SpoilerNode
spoiler_node
=
30
;
HTMLElementNode
html_element_node
=
31
;
}
}
}
}
...
@@ -257,3 +259,8 @@ message ReferencedContentNode {
...
@@ -257,3 +259,8 @@ message ReferencedContentNode {
message
SpoilerNode
{
message
SpoilerNode
{
string
content
=
1
;
string
content
=
1
;
}
}
message
HTMLElementNode
{
string
tag_name
=
1
;
map
<
string
,
string
>
attributes
=
2
;
}
proto/gen/api/v1/markdown_service.pb.go
View file @
f374169a
This diff is collapsed.
Click to expand it.
server/router/api/v1/markdown_service.go
View file @
f374169a
...
@@ -116,6 +116,8 @@ func convertFromASTNode(rawNode ast.Node) *v1pb.Node {
...
@@ -116,6 +116,8 @@ func convertFromASTNode(rawNode ast.Node) *v1pb.Node {
node
.
Node
=
&
v1pb
.
Node_ReferencedContentNode
{
ReferencedContentNode
:
&
v1pb
.
ReferencedContentNode
{
ResourceName
:
n
.
ResourceName
,
Params
:
n
.
Params
}}
node
.
Node
=
&
v1pb
.
Node_ReferencedContentNode
{
ReferencedContentNode
:
&
v1pb
.
ReferencedContentNode
{
ResourceName
:
n
.
ResourceName
,
Params
:
n
.
Params
}}
case
*
ast
.
Spoiler
:
case
*
ast
.
Spoiler
:
node
.
Node
=
&
v1pb
.
Node_SpoilerNode
{
SpoilerNode
:
&
v1pb
.
SpoilerNode
{
Content
:
n
.
Content
}}
node
.
Node
=
&
v1pb
.
Node_SpoilerNode
{
SpoilerNode
:
&
v1pb
.
SpoilerNode
{
Content
:
n
.
Content
}}
case
*
ast
.
HTMLElement
:
node
.
Node
=
&
v1pb
.
Node_HtmlElementNode
{
HtmlElementNode
:
&
v1pb
.
HTMLElementNode
{
TagName
:
n
.
TagName
,
Attributes
:
n
.
Attributes
}}
default
:
default
:
node
.
Node
=
&
v1pb
.
Node_TextNode
{
TextNode
:
&
v1pb
.
TextNode
{}}
node
.
Node
=
&
v1pb
.
Node_TextNode
{
TextNode
:
&
v1pb
.
TextNode
{}}
}
}
...
@@ -209,6 +211,8 @@ func convertToASTNode(node *v1pb.Node) ast.Node {
...
@@ -209,6 +211,8 @@ func convertToASTNode(node *v1pb.Node) ast.Node {
return
&
ast
.
ReferencedContent
{
ResourceName
:
n
.
ReferencedContentNode
.
ResourceName
,
Params
:
n
.
ReferencedContentNode
.
Params
}
return
&
ast
.
ReferencedContent
{
ResourceName
:
n
.
ReferencedContentNode
.
ResourceName
,
Params
:
n
.
ReferencedContentNode
.
Params
}
case
*
v1pb
.
Node_SpoilerNode
:
case
*
v1pb
.
Node_SpoilerNode
:
return
&
ast
.
Spoiler
{
Content
:
n
.
SpoilerNode
.
Content
}
return
&
ast
.
Spoiler
{
Content
:
n
.
SpoilerNode
.
Content
}
case
*
v1pb
.
Node_HtmlElementNode
:
return
&
ast
.
HTMLElement
{
TagName
:
n
.
HtmlElementNode
.
TagName
,
Attributes
:
n
.
HtmlElementNode
.
Attributes
}
default
:
default
:
return
&
ast
.
Text
{}
return
&
ast
.
Text
{}
}
}
...
...
web/src/components/MemoContent/HTMLElement.tsx
0 → 100644
View file @
f374169a
import
{
createElement
}
from
"react"
;
interface
Props
{
tagName
:
string
;
attributes
:
{
[
key
:
string
]:
string
};
}
const
HTMLElement
:
React
.
FC
<
Props
>
=
({
tagName
,
attributes
}:
Props
)
=>
{
return
createElement
(
tagName
,
attributes
);
};
export
default
HTMLElement
;
web/src/components/MemoContent/Renderer.tsx
View file @
f374169a
...
@@ -10,6 +10,7 @@ import {
...
@@ -10,6 +10,7 @@ import {
HeadingNode
,
HeadingNode
,
HighlightNode
,
HighlightNode
,
HorizontalRuleNode
,
HorizontalRuleNode
,
HTMLElementNode
,
ImageNode
,
ImageNode
,
ItalicNode
,
ItalicNode
,
LinkNode
,
LinkNode
,
...
@@ -37,6 +38,7 @@ import Code from "./Code";
...
@@ -37,6 +38,7 @@ import Code from "./Code";
import
CodeBlock
from
"./CodeBlock"
;
import
CodeBlock
from
"./CodeBlock"
;
import
EmbeddedContent
from
"./EmbeddedContent"
;
import
EmbeddedContent
from
"./EmbeddedContent"
;
import
EscapingCharacter
from
"./EscapingCharacter"
;
import
EscapingCharacter
from
"./EscapingCharacter"
;
import
HTMLElement
from
"./HTMLElement"
;
import
Heading
from
"./Heading"
;
import
Heading
from
"./Heading"
;
import
Highlight
from
"./Highlight"
;
import
Highlight
from
"./Highlight"
;
import
HorizontalRule
from
"./HorizontalRule"
;
import
HorizontalRule
from
"./HorizontalRule"
;
...
@@ -123,6 +125,8 @@ const Renderer: React.FC<Props> = ({ index, node }: Props) => {
...
@@ -123,6 +125,8 @@ const Renderer: React.FC<Props> = ({ index, node }: Props) => {
return
<
ReferencedContent
{
...
(
node
.
referencedContentNode
as
ReferencedContentNode
)}
/>;
return
<
ReferencedContent
{
...
(
node
.
referencedContentNode
as
ReferencedContentNode
)}
/>;
case
NodeType
.
SPOILER
:
case
NodeType
.
SPOILER
:
return
<
Spoiler
{
...
(
node
.
spoilerNode
as
SpoilerNode
)}
/>;
return
<
Spoiler
{
...
(
node
.
spoilerNode
as
SpoilerNode
)}
/>;
case
NodeType
.
HTML_ELEMENT
:
return
<
HTMLElement
{
...
(
node
.
htmlElementNode
as
HTMLElementNode
)}
/>;
default
:
default
:
return
null
;
return
null
;
}
}
...
...
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