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
13b911eb
Commit
13b911eb
authored
Feb 20, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add spoiler node
parent
4a6da917
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
1 deletion
+36
-1
gomark.wasm
web/src/assets/gomark.wasm
+0
-0
Renderer.tsx
web/src/components/MemoContent/Renderer.tsx
+4
-0
Spoiler.tsx
web/src/components/MemoContent/Spoiler.tsx
+24
-0
node.ts
web/src/types/node.ts
+8
-1
No files found.
web/src/assets/gomark.wasm
View file @
13b911eb
No preview for this file type
web/src/components/MemoContent/Renderer.tsx
View file @
13b911eb
...
@@ -19,6 +19,7 @@ import {
...
@@ -19,6 +19,7 @@ import {
OrderedListNode
,
OrderedListNode
,
ParagraphNode
,
ParagraphNode
,
ReferencedContentNode
,
ReferencedContentNode
,
SpoilerNode
,
StrikethroughNode
,
StrikethroughNode
,
SubscriptNode
,
SubscriptNode
,
SuperscriptNode
,
SuperscriptNode
,
...
@@ -46,6 +47,7 @@ import Math from "./Math";
...
@@ -46,6 +47,7 @@ import Math from "./Math";
import
OrderedList
from
"./OrderedList"
;
import
OrderedList
from
"./OrderedList"
;
import
Paragraph
from
"./Paragraph"
;
import
Paragraph
from
"./Paragraph"
;
import
ReferencedContent
from
"./ReferencedContent"
;
import
ReferencedContent
from
"./ReferencedContent"
;
import
Spoiler
from
"./Spoiler"
;
import
Strikethrough
from
"./Strikethrough"
;
import
Strikethrough
from
"./Strikethrough"
;
import
Subscript
from
"./Subscript"
;
import
Subscript
from
"./Subscript"
;
import
Superscript
from
"./Superscript"
;
import
Superscript
from
"./Superscript"
;
...
@@ -118,6 +120,8 @@ const Renderer: React.FC<Props> = ({ index, node }: Props) => {
...
@@ -118,6 +120,8 @@ const Renderer: React.FC<Props> = ({ index, node }: Props) => {
return
<
Superscript
{
...
(
node
.
superscriptNode
as
SuperscriptNode
)}
/>;
return
<
Superscript
{
...
(
node
.
superscriptNode
as
SuperscriptNode
)}
/>;
case
NodeType
.
REFERENCED_CONTENT
:
case
NodeType
.
REFERENCED_CONTENT
:
return
<
ReferencedContent
{
...
(
node
.
referencedContentNode
as
ReferencedContentNode
)}
/>;
return
<
ReferencedContent
{
...
(
node
.
referencedContentNode
as
ReferencedContentNode
)}
/>;
case
NodeType
.
SPOILER
:
return
<
Spoiler
{
...
(
node
.
spoilerNode
as
SpoilerNode
)}
/>;
default
:
default
:
return
null
;
return
null
;
}
}
...
...
web/src/components/MemoContent/Spoiler.tsx
0 → 100644
View file @
13b911eb
import
classNames
from
"classnames"
;
import
{
useState
}
from
"react"
;
interface
Props
{
content
:
string
;
}
const
Spoiler
:
React
.
FC
<
Props
>
=
({
content
}:
Props
)
=>
{
const
[
isRevealed
,
setIsRevealed
]
=
useState
(
false
);
return
(
<
div
className=
{
classNames
(
"inline cursor-pointer select-none transition-all"
,
isRevealed
?
"bg-gray-100 dark:bg-zinc-700"
:
"bg-gray-200 dark:bg-zinc-600"
,
)
}
onClick=
{
()
=>
setIsRevealed
(
!
isRevealed
)
}
>
<
span
className=
{
classNames
(
isRevealed
?
"opacity-100"
:
"opacity-0"
)
}
>
{
content
}
</
span
>
</
div
>
);
};
export
default
Spoiler
;
web/src/types/node.ts
View file @
13b911eb
...
@@ -32,6 +32,7 @@ export enum NodeType {
...
@@ -32,6 +32,7 @@ export enum NodeType {
SUBSCRIPT
=
"SUBSCRIPT"
,
SUBSCRIPT
=
"SUBSCRIPT"
,
SUPERSCRIPT
=
"SUPERSCRIPT"
,
SUPERSCRIPT
=
"SUPERSCRIPT"
,
REFERENCED_CONTENT
=
"REFERENCED_CONTENT"
,
REFERENCED_CONTENT
=
"REFERENCED_CONTENT"
,
SPOILER
=
"SPOILER"
,
UNRECOGNIZED
=
"UNRECOGNIZED"
,
UNRECOGNIZED
=
"UNRECOGNIZED"
,
}
}
...
@@ -65,9 +66,11 @@ export interface Node {
...
@@ -65,9 +66,11 @@ export interface Node {
subscriptNode
?:
SubscriptNode
|
undefined
;
subscriptNode
?:
SubscriptNode
|
undefined
;
superscriptNode
?:
SuperscriptNode
|
undefined
;
superscriptNode
?:
SuperscriptNode
|
undefined
;
referencedContentNode
?:
ReferencedContentNode
|
undefined
;
referencedContentNode
?:
ReferencedContentNode
|
undefined
;
spoilerNode
?:
SpoilerNode
|
undefined
;
}
}
export
interface
LineBreakNode
{}
export
interface
LineBreakNode
{
}
export
interface
ParagraphNode
{
export
interface
ParagraphNode
{
children
:
Node
[];
children
:
Node
[];
...
@@ -199,3 +202,7 @@ export interface ReferencedContentNode {
...
@@ -199,3 +202,7 @@ export interface ReferencedContentNode {
resourceName
:
string
;
resourceName
:
string
;
params
:
string
;
params
:
string
;
}
}
export
interface
SpoilerNode
{
content
:
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