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
5fa9aa3c
Commit
5fa9aa3c
authored
Sep 08, 2022
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add memo resources component
parent
fbce4387
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
61 additions
and
57 deletions
+61
-57
Memo.tsx
web/src/components/Memo.tsx
+5
-12
MemoCardDialog.tsx
web/src/components/MemoCardDialog.tsx
+3
-10
MemoResources.tsx
web/src/components/MemoResources.tsx
+28
-0
Sidebar.tsx
web/src/components/Sidebar.tsx
+3
-3
memo-card-dialog.less
web/src/less/memo-card-dialog.less
+0
-17
memo-editor.less
web/src/less/memo-editor.less
+1
-1
memo-resources.less
web/src/less/memo-resources.less
+19
-0
memo.less
web/src/less/memo.less
+0
-14
Explore.tsx
web/src/pages/Explore.tsx
+2
-0
No files found.
web/src/components/Memo.tsx
View file @
5fa9aa3c
import
{
memo
,
useEffect
,
useRef
,
useState
}
from
"react"
;
import
{
indexOf
}
from
"lodash-es"
;
import
dayjs
from
"dayjs"
;
import
relativeTime
from
"dayjs/plugin/relativeTime"
;
import
{
indexOf
}
from
"lodash-es"
;
import
{
memo
,
useEffect
,
useRef
,
useState
}
from
"react"
;
import
"dayjs/locale/zh"
;
import
useI18n
from
"../hooks/useI18n"
;
import
{
UNKNOWN_ID
}
from
"../helpers/consts"
;
import
{
DONE_BLOCK_REG
,
formatMemoContent
,
IMAGE_URL_REG
,
TODO_BLOCK_REG
}
from
"../helpers/marked"
;
import
{
DONE_BLOCK_REG
,
formatMemoContent
,
TODO_BLOCK_REG
}
from
"../helpers/marked"
;
import
{
editorStateService
,
locationService
,
memoService
,
userService
}
from
"../services"
;
import
Icon
from
"./Icon"
;
import
Only
from
"./common/OnlyWhen"
;
import
toastHelper
from
"./Toast"
;
import
Image
from
"./Image
"
;
import
MemoResources
from
"./MemoResources
"
;
import
showMemoCardDialog
from
"./MemoCardDialog"
;
import
showShareMemoImageDialog
from
"./ShareMemoImageDialog"
;
import
"../less/memo.less"
;
...
...
@@ -46,7 +46,6 @@ const Memo: React.FC<Props> = (props: Props) => {
const
[
createdAtStr
,
setCreatedAtStr
]
=
useState
<
string
>
(
getFormatedMemoCreatedAtStr
(
memo
.
createdTs
,
locale
));
const
memoContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
memoContentContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
imageUrls
=
Array
.
from
(
memo
.
content
.
match
(
IMAGE_URL_REG
)
??
[]).
map
((
s
)
=>
s
.
replace
(
IMAGE_URL_REG
,
"$1"
));
const
isVisitorMode
=
userService
.
isVisitorMode
();
useEffect
(()
=>
{
...
...
@@ -239,13 +238,7 @@ const Memo: React.FC<Props> = (props: Props) => {
</
span
>
</
div
>
)
}
<
Only
when=
{
imageUrls
.
length
>
0
}
>
<
div
className=
"images-wrapper"
>
{
imageUrls
.
map
((
imgUrl
,
idx
)
=>
(
<
Image
className=
"memo-img"
key=
{
idx
}
imgUrl=
{
imgUrl
}
/>
))
}
</
div
>
</
Only
>
<
MemoResources
memo=
{
memo
}
/>
</
div
>
);
};
...
...
web/src/components/MemoCardDialog.tsx
View file @
5fa9aa3c
...
...
@@ -3,13 +3,13 @@ import { editorStateService, memoService, userService } from "../services";
import
{
useAppSelector
}
from
"../store"
;
import
{
UNKNOWN_ID
,
VISIBILITY_SELECTOR_ITEMS
}
from
"../helpers/consts"
;
import
*
as
utils
from
"../helpers/utils"
;
import
{
formatMemoContent
,
IMAGE_URL_REG
,
MEMO_LINK_REG
,
parseHtmlToRawText
}
from
"../helpers/marked"
;
import
{
formatMemoContent
,
MEMO_LINK_REG
,
parseHtmlToRawText
}
from
"../helpers/marked"
;
import
Only
from
"./common/OnlyWhen"
;
import
toastHelper
from
"./Toast"
;
import
{
generateDialog
}
from
"./Dialog"
;
import
Image
from
"./Image"
;
import
Icon
from
"./Icon"
;
import
Selector
from
"./common/Selector"
;
import
MemoResources
from
"./MemoResources"
;
import
showChangeMemoCreatedTsDialog
from
"./ChangeMemoCreatedTsDialog"
;
import
"../less/memo-card-dialog.less"
;
...
...
@@ -29,7 +29,6 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
});
const
[
linkMemos
,
setLinkMemos
]
=
useState
<
LinkedMemo
[]
>
([]);
const
[
linkedMemos
,
setLinkedMemos
]
=
useState
<
LinkedMemo
[]
>
([]);
const
imageUrls
=
Array
.
from
(
memo
.
content
.
match
(
IMAGE_URL_REG
)
??
[]).
map
((
s
)
=>
s
.
replace
(
IMAGE_URL_REG
,
"$1"
));
useEffect
(()
=>
{
const
fetchLinkedMemos
=
async
()
=>
{
...
...
@@ -167,13 +166,7 @@ const MemoCardDialog: React.FC<Props> = (props: Props) => {
onClick=
{
handleMemoContentClick
}
dangerouslySetInnerHTML=
{
{
__html
:
formatMemoContent
(
memo
.
content
)
}
}
></
div
>
<
Only
when=
{
imageUrls
.
length
>
0
}
>
<
div
className=
"images-wrapper"
>
{
imageUrls
.
map
((
imgUrl
,
idx
)
=>
(
<
Image
className=
"memo-img"
key=
{
idx
}
imgUrl=
{
imgUrl
}
/>
))
}
</
div
>
</
Only
>
<
MemoResources
memo=
{
memo
}
/>
</
div
>
<
div
className=
"layer-container"
></
div
>
{
linkMemos
.
map
((
_
,
idx
)
=>
{
...
...
web/src/components/MemoResources.tsx
0 → 100644
View file @
5fa9aa3c
import
{
IMAGE_URL_REG
}
from
"../helpers/marked"
;
import
Only
from
"./common/OnlyWhen"
;
import
Image
from
"./Image"
;
import
"../less/memo-resources.less"
;
interface
Props
{
className
?:
string
;
memo
:
Memo
;
}
const
MemoResources
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
className
,
memo
}
=
props
;
const
imageUrls
=
Array
.
from
(
memo
.
content
.
match
(
IMAGE_URL_REG
)
??
[]).
map
((
s
)
=>
s
.
replace
(
IMAGE_URL_REG
,
"$1"
));
return
(
<
div
className=
"resource-wrapper"
>
<
Only
when=
{
imageUrls
.
length
>
0
}
>
<
div
className=
{
`images-wrapper ${className ?? ""}`
}
>
{
imageUrls
.
map
((
imgUrl
,
idx
)
=>
(
<
Image
className=
"memo-img"
key=
{
idx
}
imgUrl=
{
imgUrl
}
/>
))
}
</
div
>
</
Only
>
</
div
>
);
};
export
default
MemoResources
;
web/src/components/Sidebar.tsx
View file @
5fa9aa3c
...
...
@@ -35,12 +35,12 @@ const Sidebar = () => {
<
span
className=
"icon"
>
📅
</
span
>
{
t
(
"sidebar.daily-review"
)
}
</
button
>
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
<
button
className=
"btn action-btn"
onClick=
{
handleSettingBtnClick
}
>
<
span
className=
"icon"
>
⚙️
</
span
>
{
t
(
"sidebar.setting"
)
}
</
button
>
<
button
className=
"btn action-btn"
onClick=
{
()
=>
handleExploreBtnClick
()
}
>
<
span
className=
"icon"
>
🏂
</
span
>
{
t
(
"common.explore"
)
}
</
button
>
<
button
className=
"btn action-btn"
onClick=
{
handleSettingBtnClick
}
>
<
span
className=
"icon"
>
⚙️
</
span
>
{
t
(
"sidebar.setting"
)
}
</
button
>
</
Only
>
</
div
>
<
Only
when=
{
!
userService
.
isVisitorMode
()
}
>
...
...
web/src/less/memo-card-dialog.less
View file @
5fa9aa3c
...
...
@@ -61,23 +61,6 @@
> .memo-content-text {
@apply w-full text-base;
}
> .images-wrapper {
.flex(row, flex-start, flex-start);
@apply w-full mt-2 overflow-x-auto overflow-y-hidden;
padding-bottom: 2px;
.pretty-scroll-bar(0, 2px);
> .memo-img {
@apply mr-2 w-auto h-32 shrink-0 grow-0 overflow-y-hidden hover:border-gray-400 last:mr-0;
.hide-scroll-bar();
> img {
@apply w-auto rounded-lg;
max-height: 128px;
}
}
}
}
> .normal-text {
...
...
web/src/less/memo-editor.less
View file @
5fa9aa3c
...
...
@@ -50,7 +50,7 @@
}
> .tag-list {
@apply hidden flex-col justify-start items-start absolute top-6 left-0 mt-1 p-1 z-1 rounded w-32 max-h-52 overflow-auto bg-black;
@apply hidden flex-col justify-start items-start absolute top-6 left-0 mt-1 p-1 z-1 rounded w-32 max-h-52 overflow-auto
font-mono
bg-black;
> .item-container {
@apply w-full text-white cursor-pointer rounded text-sm leading-6 px-2 hover:bg-gray-700;
...
...
web/src/less/memo-resources.less
0 → 100644
View file @
5fa9aa3c
@import "./mixin.less";
.resource-wrapper {
@apply w-full flex flex-col justify-start items-start;
> .images-wrapper {
@apply flex flex-row justify-start items-start mt-2 w-full overflow-x-auto overflow-y-hidden pb-1;
.pretty-scroll-bar(0, 2px);
> .memo-img {
@apply mr-2 last:mr-0 w-auto h-auto shrink-0 grow-0 overflow-y-hidden;
.hide-scroll-bar();
> img {
@apply w-auto max-h-40 rounded-lg;
}
}
}
}
web/src/less/memo.less
View file @
5fa9aa3c
...
...
@@ -140,18 +140,4 @@
}
}
}
> .images-wrapper {
@apply flex flex-row justify-start items-start mt-2 w-full overflow-x-auto overflow-y-hidden pb-1;
.pretty-scroll-bar(0, 2px);
> .memo-img {
@apply mr-2 last:mr-0 w-auto h-auto shrink-0 grow-0 overflow-y-hidden;
.hide-scroll-bar();
> img {
@apply w-auto max-h-40 rounded-lg;
}
}
}
}
web/src/pages/Explore.tsx
View file @
5fa9aa3c
...
...
@@ -5,6 +5,7 @@ import { useAppSelector } from "../store";
import
useI18n
from
"../hooks/useI18n"
;
import
useLoading
from
"../hooks/useLoading"
;
import
MemoContent
from
"../components/MemoContent"
;
import
MemoResources
from
"../components/MemoResources"
;
import
"../less/explore.less"
;
interface
State
{
...
...
@@ -72,6 +73,7 @@ const Explore = () => {
</
a
>
</
div
>
<
MemoContent
className=
"memo-content"
content=
{
memo
.
content
}
onMemoContentClick=
{
()
=>
undefined
}
/>
<
MemoResources
memo=
{
memo
}
/>
</
div
>
);
})
}
...
...
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