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
8c312e64
Unverified
Commit
8c312e64
authored
Aug 24, 2023
by
boojack
Committed by
GitHub
Aug 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: remove auto collapse setting (#2169)
parent
d3bd3dda
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
7 additions
and
70 deletions
+7
-70
DailyMemo.tsx
web/src/components/DailyMemo.tsx
+1
-1
Memo.tsx
web/src/components/Memo.tsx
+1
-3
MemoContent.tsx
web/src/components/MemoContent.tsx
+3
-53
PreferencesSection.tsx
web/src/components/Settings/PreferencesSection.tsx
+0
-9
ShareMemoDialog.tsx
web/src/components/ShareMemoDialog.tsx
+1
-1
MemoDetail.tsx
web/src/pages/MemoDetail.tsx
+1
-1
user.ts
web/src/store/module/user.ts
+0
-1
setting.d.ts
web/src/types/modules/setting.d.ts
+0
-1
No files found.
web/src/components/DailyMemo.tsx
View file @
8c312e64
...
...
@@ -17,7 +17,7 @@ const DailyMemo: React.FC<Props> = (props: Props) => {
<
span
className=
"normal-text"
>
{
displayTimeStr
}
</
span
>
</
div
>
<
div
className=
"memo-container"
>
<
MemoContent
content=
{
memo
.
content
}
showFull=
{
true
}
/>
<
MemoContent
content=
{
memo
.
content
}
/>
<
MemoResourceListView
resourceList=
{
memo
.
resourceList
}
/>
</
div
>
<
div
className=
"split-line"
></
div
>
...
...
web/src/components/Memo.tsx
View file @
8c312e64
...
...
@@ -24,14 +24,13 @@ import "@/less/memo.less";
interface
Props
{
memo
:
Memo
;
showCreator
?:
boolean
;
showFull
?:
boolean
;
showVisibility
?:
boolean
;
showRelatedMemos
?:
boolean
;
lazyRendering
?:
boolean
;
}
const
Memo
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
memo
,
showCreator
,
show
Full
,
show
RelatedMemos
,
lazyRendering
}
=
props
;
const
{
memo
,
showCreator
,
showRelatedMemos
,
lazyRendering
}
=
props
;
const
{
i18n
}
=
useTranslation
();
const
t
=
useTranslate
();
const
filterStore
=
useFilterStore
();
...
...
@@ -303,7 +302,6 @@ const Memo: React.FC<Props> = (props: Props) => {
</
div
>
<
MemoContent
content=
{
memo
.
content
}
showFull=
{
showFull
}
onMemoContentClick=
{
handleMemoContentClick
}
onMemoContentDoubleClick=
{
handleMemoContentDoubleClick
}
/>
...
...
web/src/components/MemoContent.tsx
View file @
8c312e64
import
{
use
Effect
,
useRef
,
useState
}
from
"react"
;
import
{
use
Ref
}
from
"react"
;
import
{
marked
}
from
"@/labs/marked"
;
import
{
useUserStore
}
from
"@/store/module"
;
import
{
useTranslate
}
from
"@/utils/i18n"
;
import
Icon
from
"./Icon"
;
import
"@/less/memo-content.less"
;
const
MAX_EXPAND_HEIGHT
=
384
;
interface
Props
{
content
:
string
;
className
?:
string
;
showFull
?:
boolean
;
onMemoContentClick
?:
(
e
:
React
.
MouseEvent
)
=>
void
;
onMemoContentDoubleClick
?:
(
e
:
React
.
MouseEvent
)
=>
void
;
}
type
ExpandButtonStatus
=
-
1
|
0
|
1
;
interface
State
{
expandButtonStatus
:
ExpandButtonStatus
;
}
const
MemoContent
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
className
,
content
,
showFull
,
onMemoContentClick
,
onMemoContentDoubleClick
}
=
props
;
const
t
=
useTranslate
();
const
userStore
=
useUserStore
();
const
[
state
,
setState
]
=
useState
<
State
>
({
expandButtonStatus
:
-
1
,
});
const
{
className
,
content
,
onMemoContentClick
,
onMemoContentDoubleClick
}
=
props
;
const
memoContentContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
isVisitorMode
=
userStore
.
isVisitorMode
();
const
autoCollapse
:
boolean
=
!
showFull
&&
(
isVisitorMode
?
true
:
(
userStore
.
state
.
user
as
User
).
localSetting
.
enableAutoCollapse
);
useEffect
(()
=>
{
if
(
!
autoCollapse
)
{
return
;
}
if
(
memoContentContainerRef
.
current
)
{
const
height
=
memoContentContainerRef
.
current
.
scrollHeight
;
if
(
height
>
MAX_EXPAND_HEIGHT
)
{
setState
({
expandButtonStatus
:
0
,
});
}
}
},
[
autoCollapse
]);
const
handleMemoContentClick
=
async
(
e
:
React
.
MouseEvent
)
=>
{
if
(
onMemoContentClick
)
{
...
...
@@ -59,32 +25,16 @@ const MemoContent: React.FC<Props> = (props: Props) => {
}
};
const
handleExpandBtnClick
=
()
=>
{
const
expandButtonStatus
=
Boolean
(
!
state
.
expandButtonStatus
);
setState
({
expandButtonStatus
:
Number
(
expandButtonStatus
)
as
ExpandButtonStatus
,
});
};
return
(
<
div
className=
{
`memo-content-wrapper ${className || ""}`
}
>
<
div
ref=
{
memoContentContainerRef
}
className=
{
`memo-content-text ${autoCollapse && state.expandButtonStatus < 1 ? "max-h-64 overflow-y-hidden" : ""}`
}
className=
"memo-content-text"
onClick=
{
handleMemoContentClick
}
onDoubleClick=
{
handleMemoContentDoubleClick
}
>
{
marked
(
content
)
}
</
div
>
{
autoCollapse
&&
state
.
expandButtonStatus
!==
-
1
&&
(
<
div
className=
{
`expand-btn-container ${state.expandButtonStatus === 0 && "!-mt-7"}`
}
>
<
div
className=
"absolute top-0 left-0 w-full h-full blur-lg bg-white dark:bg-zinc-700"
></
div
>
<
span
className=
{
`btn z-10 ${state.expandButtonStatus === 0 ? "expand-btn" : "fold-btn"}`
}
onClick=
{
handleExpandBtnClick
}
>
{
state
.
expandButtonStatus
===
0
?
t
(
"common.expand"
)
:
t
(
"common.fold"
)
}
<
Icon
.
ChevronRight
className=
"icon-img opacity-80"
/>
</
span
>
</
div
>
)
}
</
div
>
);
};
...
...
web/src/components/Settings/PreferencesSection.tsx
View file @
8c312e64
...
...
@@ -47,10 +47,6 @@ const PreferencesSection = () => {
userStore
.
upsertLocalSetting
({
...
localSetting
,
dailyReviewTimeOffset
:
value
});
};
const
handleAutoCollapseChanged
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
userStore
.
upsertLocalSetting
({
...
localSetting
,
enableAutoCollapse
:
event
.
target
.
checked
});
};
const
handleSaveTelegramUserId
=
async
()
=>
{
try
{
await
userStore
.
upsertUserSetting
(
"telegram-user-id"
,
telegramUserId
);
...
...
@@ -130,11 +126,6 @@ const PreferencesSection = () => {
<
Switch
className=
"ml-2"
checked=
{
localSetting
.
enableDoubleClickEditing
}
onChange=
{
handleDoubleClickEnabledChanged
}
/>
</
label
>
<
label
className=
"form-label selector"
>
<
span
className=
"normal-text"
>
{
t
(
"setting.preference-section.auto-collapse"
)
}
</
span
>
<
Switch
className=
"ml-2"
checked=
{
localSetting
.
enableAutoCollapse
}
onChange=
{
handleAutoCollapseChanged
}
/>
</
label
>
<
Divider
className=
"!mt-3 !my-4"
/>
<
div
className=
"mb-2 w-full flex flex-row justify-between items-center"
>
...
...
web/src/components/ShareMemoDialog.tsx
View file @
8c312e64
...
...
@@ -174,7 +174,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
>
<
span
className=
"w-full px-6 pt-5 pb-2 text-sm text-gray-500"
>
{
memo
.
displayTsStr
}
</
span
>
<
div
className=
"w-full px-6 text-base pb-4"
>
<
MemoContent
content=
{
memo
.
content
}
showFull=
{
true
}
/>
<
MemoContent
content=
{
memo
.
content
}
/>
<
MemoResourceListView
className=
"!grid-cols-2"
resourceList=
{
memo
.
resourceList
}
/>
</
div
>
<
div
className=
"flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-700 py-4 px-6"
>
...
...
web/src/pages/MemoDetail.tsx
View file @
8c312e64
...
...
@@ -45,7 +45,7 @@ const MemoDetail = () => {
(
memo
?
(
<>
<
main
className=
"relative flex-grow max-w-2xl w-full min-h-full flex flex-col justify-start items-start px-4"
>
<
Memo
memo=
{
memo
}
showCreator
show
Full
show
RelatedMemos
/>
<
Memo
memo=
{
memo
}
showCreator
showRelatedMemos
/>
</
main
>
<
div
className=
"mt-4 w-full flex flex-row justify-center items-center gap-2"
>
<
Link
...
...
web/src/store/module/user.ts
View file @
8c312e64
...
...
@@ -16,7 +16,6 @@ const defaultSetting: Setting = {
const
defaultLocalSetting
:
LocalSetting
=
{
enableDoubleClickEditing
:
false
,
enableAutoCollapse
:
false
,
dailyReviewTimeOffset
:
0
,
};
...
...
web/src/types/modules/setting.d.ts
View file @
8c312e64
...
...
@@ -13,7 +13,6 @@ interface Setting {
interface
LocalSetting
{
enableDoubleClickEditing
:
boolean
;
enableAutoCollapse
:
boolean
;
dailyReviewTimeOffset
:
number
;
}
...
...
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