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
c7aaf791
Commit
c7aaf791
authored
Mar 29, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: tweak props naming
parent
239348c4
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
56 additions
and
68 deletions
+56
-68
MemoActionMenu.tsx
web/src/components/MemoActionMenu.tsx
+2
-2
EmbeddedMemo.tsx
...c/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
+3
-3
TaskList.tsx
web/src/components/MemoContent/TaskList.tsx
+2
-2
index.tsx
web/src/components/MemoContent/index.tsx
+4
-4
context.ts
web/src/components/MemoContent/types/context.ts
+1
-1
AddMemoRelationButton.tsx
...ponents/MemoEditor/ActionButton/AddMemoRelationButton.tsx
+2
-2
MemoEditorDialog.tsx
web/src/components/MemoEditor/MemoEditorDialog.tsx
+7
-7
index.tsx
web/src/components/MemoEditor/index.tsx
+21
-27
context.ts
web/src/components/MemoEditor/types/context.ts
+1
-2
MemoRelationListView.tsx
web/src/components/MemoRelationListView.tsx
+1
-1
MemoView.tsx
web/src/components/MemoView.tsx
+1
-1
ShareMemoDialog.tsx
web/src/components/ShareMemoDialog.tsx
+1
-1
Archived.tsx
web/src/pages/Archived.tsx
+2
-7
Home.tsx
web/src/pages/Home.tsx
+2
-2
MemoDetail.tsx
web/src/pages/MemoDetail.tsx
+3
-3
Resources.tsx
web/src/pages/Resources.tsx
+3
-3
No files found.
web/src/components/MemoActionMenu.tsx
View file @
c7aaf791
...
@@ -52,8 +52,8 @@ const MemoActionMenu = (props: Props) => {
...
@@ -52,8 +52,8 @@ const MemoActionMenu = (props: Props) => {
const
handleEditMemoClick
=
()
=>
{
const
handleEditMemoClick
=
()
=>
{
showMemoEditorDialog
({
showMemoEditorDialog
({
memo
Id
:
extractMemoIdFromName
(
memo
.
name
)
,
memo
Name
:
memo
.
name
,
cacheKey
:
`
${
memo
.
name
}
-
${
memo
.
update
Time
}
`
,
cacheKey
:
`
${
memo
.
name
}
-
${
memo
.
display
Time
}
`
,
});
});
};
};
...
...
web/src/components/MemoContent/EmbeddedContent/EmbeddedMemo.tsx
View file @
c7aaf791
...
@@ -30,7 +30,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
...
@@ -30,7 +30,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
if
(
!
memo
)
{
if
(
!
memo
)
{
return
<
Error
message=
{
`Memo not found: ${resourceId}`
}
/>;
return
<
Error
message=
{
`Memo not found: ${resourceId}`
}
/>;
}
}
if
(
extractMemoIdFromName
(
memo
.
name
)
===
context
.
memoId
||
context
.
embeddedMemos
.
has
(
resourceName
))
{
if
(
memo
.
name
===
context
.
memoName
||
context
.
embeddedMemos
.
has
(
resourceName
))
{
return
<
Error
message=
{
`Nested Rendering Error: ![[${resourceName}]]`
}
/>;
return
<
Error
message=
{
`Nested Rendering Error: ![[${resourceName}]]`
}
/>;
}
}
...
@@ -43,7 +43,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
...
@@ -43,7 +43,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
<
div
className=
"w-full"
>
<
div
className=
"w-full"
>
<
MemoContent
<
MemoContent
key=
{
`${memo.name}-${memo.updateTime}`
}
key=
{
`${memo.name}-${memo.updateTime}`
}
memo
Id=
{
extractMemoIdFromName
(
memo
.
name
)
}
memo
Name=
{
memo
.
name
}
content=
{
memo
.
content
}
content=
{
memo
.
content
}
embeddedMemos=
{
context
.
embeddedMemos
}
embeddedMemos=
{
context
.
embeddedMemos
}
/>
/>
...
@@ -64,7 +64,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
...
@@ -64,7 +64,7 @@ const EmbeddedMemo = ({ resourceId, params: paramsStr }: Props) => {
</
div
>
</
div
>
<
MemoContent
<
MemoContent
key=
{
`${memo.name}-${memo.updateTime}`
}
key=
{
`${memo.name}-${memo.updateTime}`
}
memo
Id=
{
extractMemoIdFromName
(
memo
.
name
)
}
memo
Name=
{
memo
.
name
}
content=
{
memo
.
content
}
content=
{
memo
.
content
}
embeddedMemos=
{
context
.
embeddedMemos
}
embeddedMemos=
{
context
.
embeddedMemos
}
/>
/>
...
...
web/src/components/MemoContent/TaskList.tsx
View file @
c7aaf791
...
@@ -21,7 +21,7 @@ const TaskList: React.FC<Props> = ({ index, indent, complete, children }: Props)
...
@@ -21,7 +21,7 @@ const TaskList: React.FC<Props> = ({ index, indent, complete, children }: Props)
const
[
checked
]
=
useState
(
complete
);
const
[
checked
]
=
useState
(
complete
);
const
handleCheckboxChange
=
async
(
on
:
boolean
)
=>
{
const
handleCheckboxChange
=
async
(
on
:
boolean
)
=>
{
if
(
context
.
readonly
||
!
context
.
memo
Id
)
{
if
(
context
.
readonly
||
!
context
.
memo
Name
)
{
return
;
return
;
}
}
...
@@ -39,7 +39,7 @@ const TaskList: React.FC<Props> = ({ index, indent, complete, children }: Props)
...
@@ -39,7 +39,7 @@ const TaskList: React.FC<Props> = ({ index, indent, complete, children }: Props)
const
content
=
window
.
restore
(
context
.
nodes
);
const
content
=
window
.
restore
(
context
.
nodes
);
await
memoStore
.
updateMemo
(
await
memoStore
.
updateMemo
(
{
{
name
:
`
${
MemoNamePrefix
}${
context
.
memo
Id
}
`
,
name
:
`
${
MemoNamePrefix
}${
context
.
memo
Name
}
`
,
content
,
content
,
},
},
[
"content"
],
[
"content"
],
...
...
web/src/components/MemoContent/index.tsx
View file @
c7aaf791
...
@@ -12,7 +12,7 @@ const MAX_DISPLAY_HEIGHT = 256;
...
@@ -12,7 +12,7 @@ const MAX_DISPLAY_HEIGHT = 256;
interface
Props
{
interface
Props
{
content
:
string
;
content
:
string
;
memo
Id
?:
number
;
memo
Name
?:
string
;
compact
?:
boolean
;
compact
?:
boolean
;
readonly
?:
boolean
;
readonly
?:
boolean
;
disableFilter
?:
boolean
;
disableFilter
?:
boolean
;
...
@@ -24,13 +24,13 @@ interface Props {
...
@@ -24,13 +24,13 @@ interface Props {
}
}
const
MemoContent
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
MemoContent
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
const
{
className
,
content
,
memo
Id
,
embeddedMemos
,
onClick
}
=
props
;
const
{
className
,
content
,
memo
Name
,
embeddedMemos
,
onClick
}
=
props
;
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
currentUser
=
useCurrentUser
();
const
currentUser
=
useCurrentUser
();
const
memoStore
=
useMemoStore
();
const
memoStore
=
useMemoStore
();
const
memoContentContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
memoContentContainerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
[
showCompactMode
,
setShowCompactMode
]
=
useState
<
boolean
>
(
false
);
const
[
showCompactMode
,
setShowCompactMode
]
=
useState
<
boolean
>
(
false
);
const
memo
=
memo
Id
?
memoStore
.
getMemoByName
(
`
${
MemoNamePrefix
}${
memoId
}
`
)
:
null
;
const
memo
=
memo
Name
?
memoStore
.
getMemoByName
(
memoName
)
:
null
;
const
nodes
=
window
.
parse
(
content
);
const
nodes
=
window
.
parse
(
content
);
const
allowEdit
=
!
props
.
readonly
&&
memo
&&
currentUser
?.
name
===
memo
.
creator
;
const
allowEdit
=
!
props
.
readonly
&&
memo
&&
currentUser
?.
name
===
memo
.
creator
;
...
@@ -62,7 +62,7 @@ const MemoContent: React.FC<Props> = (props: Props) => {
...
@@ -62,7 +62,7 @@ const MemoContent: React.FC<Props> = (props: Props) => {
<
RendererContext
.
Provider
<
RendererContext
.
Provider
value=
{
{
value=
{
{
nodes
,
nodes
,
memo
Id
,
memo
Name
:
memoName
,
readonly
:
!
allowEdit
,
readonly
:
!
allowEdit
,
disableFilter
:
props
.
disableFilter
,
disableFilter
:
props
.
disableFilter
,
embeddedMemos
:
embeddedMemos
||
new
Set
(),
embeddedMemos
:
embeddedMemos
||
new
Set
(),
...
...
web/src/components/MemoContent/types/context.ts
View file @
c7aaf791
...
@@ -6,7 +6,7 @@ interface Context {
...
@@ -6,7 +6,7 @@ interface Context {
// embeddedMemos is a set of memo resource names that are embedded in the current memo.
// embeddedMemos is a set of memo resource names that are embedded in the current memo.
// This is used to prevent infinite loops when a memo embeds itself.
// This is used to prevent infinite loops when a memo embeds itself.
embeddedMemos
:
Set
<
string
>
;
embeddedMemos
:
Set
<
string
>
;
memo
Id
?:
number
;
memo
Name
?:
string
;
readonly
?:
boolean
;
readonly
?:
boolean
;
disableFilter
?:
boolean
;
disableFilter
?:
boolean
;
}
}
...
...
web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx
View file @
c7aaf791
...
@@ -47,12 +47,12 @@ const AddMemoRelationButton = (props: Props) => {
...
@@ -47,12 +47,12 @@ const AddMemoRelationButton = (props: Props) => {
uniqBy
(
uniqBy
(
[
[
...
memos
.
map
((
memo
)
=>
({
...
memos
.
map
((
memo
)
=>
({
memo
:
`
${
MemoNamePrefix
}${
context
.
memoId
||
UNKNOWN_ID
}
`
,
memo
:
context
.
memoName
||
""
,
relatedMemo
:
memo
.
name
,
relatedMemo
:
memo
.
name
,
type
:
MemoRelation_Type
.
REFERENCE
,
type
:
MemoRelation_Type
.
REFERENCE
,
})),
})),
...
context
.
relationList
,
...
context
.
relationList
,
].
filter
((
relation
)
=>
relation
.
relatedMemo
!==
`
${
MemoNamePrefix
}${
context
.
memoId
||
UNKNOWN_ID
}
`
),
].
filter
((
relation
)
=>
relation
.
relatedMemo
!==
context
.
memoName
),
"relatedMemoId"
,
"relatedMemoId"
,
),
),
);
);
...
...
web/src/components/MemoEditor/MemoEditorDialog.tsx
View file @
c7aaf791
...
@@ -2,17 +2,17 @@ import { IconButton } from "@mui/joy";
...
@@ -2,17 +2,17 @@ import { IconButton } from "@mui/joy";
import
{
useEffect
}
from
"react"
;
import
{
useEffect
}
from
"react"
;
import
{
useGlobalStore
,
useTagStore
}
from
"@/store/module"
;
import
{
useGlobalStore
,
useTagStore
}
from
"@/store/module"
;
import
{
MemoRelation
}
from
"@/types/proto/api/v2/memo_relation_service"
;
import
{
MemoRelation
}
from
"@/types/proto/api/v2/memo_relation_service"
;
import
MemoEditor
V1
from
"."
;
import
MemoEditor
from
"."
;
import
{
generateDialog
}
from
"../Dialog"
;
import
{
generateDialog
}
from
"../Dialog"
;
import
Icon
from
"../Icon"
;
import
Icon
from
"../Icon"
;
interface
Props
extends
DialogProps
{
interface
Props
extends
DialogProps
{
memo
Id
?:
number
;
memo
Name
?:
string
;
cacheKey
?:
string
;
cacheKey
?:
string
;
relationList
?:
MemoRelation
[];
relationList
?:
MemoRelation
[];
}
}
const
MemoEditorDialog
:
React
.
FC
<
Props
>
=
({
memo
Id
,
cacheKey
,
relationList
,
destroy
}:
Props
)
=>
{
const
MemoEditorDialog
:
React
.
FC
<
Props
>
=
({
memo
Name
:
memo
,
cacheKey
,
relationList
,
destroy
}:
Props
)
=>
{
const
globalStore
=
useGlobalStore
();
const
globalStore
=
useGlobalStore
();
const
tagStore
=
useTagStore
();
const
tagStore
=
useTagStore
();
const
{
systemStatus
}
=
globalStore
.
state
;
const
{
systemStatus
}
=
globalStore
.
state
;
...
@@ -37,10 +37,10 @@ const MemoEditorDialog: React.FC<Props> = ({ memoId, cacheKey, relationList, des
...
@@ -37,10 +37,10 @@ const MemoEditorDialog: React.FC<Props> = ({ memoId, cacheKey, relationList, des
</
IconButton
>
</
IconButton
>
</
div
>
</
div
>
<
div
className=
"flex flex-col justify-start items-start max-w-full w-[36rem]"
>
<
div
className=
"flex flex-col justify-start items-start max-w-full w-[36rem]"
>
<
MemoEditor
V1
<
MemoEditor
className=
"border-none !p-0 -mb-2"
className=
"border-none !p-0 -mb-2"
cacheKey=
{
`memo-editor-${cacheKey || memo
Id
}`
}
cacheKey=
{
`memo-editor-${cacheKey || memo}`
}
memo
Id=
{
memoId
}
memo
Name=
{
memo
}
relationList=
{
relationList
}
relationList=
{
relationList
}
onConfirm=
{
handleCloseBtnClick
}
onConfirm=
{
handleCloseBtnClick
}
autoFocus
autoFocus
...
@@ -50,7 +50,7 @@ const MemoEditorDialog: React.FC<Props> = ({ memoId, cacheKey, relationList, des
...
@@ -50,7 +50,7 @@ const MemoEditorDialog: React.FC<Props> = ({ memoId, cacheKey, relationList, des
);
);
};
};
export
default
function
showMemoEditorDialog
(
props
:
Pick
<
Props
,
"memo
Id
"
|
"cacheKey"
|
"relationList"
>
=
{}):
void
{
export
default
function
showMemoEditorDialog
(
props
:
Pick
<
Props
,
"memo
Name
"
|
"cacheKey"
|
"relationList"
>
=
{}):
void
{
generateDialog
(
generateDialog
(
{
{
className
:
"memo-editor-dialog"
,
className
:
"memo-editor-dialog"
,
...
...
web/src/components/MemoEditor/index.tsx
View file @
c7aaf791
...
@@ -30,13 +30,12 @@ import { MemoEditorContext } from "./types";
...
@@ -30,13 +30,12 @@ import { MemoEditorContext } from "./types";
interface
Props
{
interface
Props
{
className
?:
string
;
className
?:
string
;
editorClassName
?:
string
;
cacheKey
?:
string
;
cacheKey
?:
string
;
memo
Id
?:
number
;
memo
Name
?:
string
;
parentMemo
Id
?:
number
;
parentMemo
Name
?:
string
;
relationList
?:
MemoRelation
[];
relationList
?:
MemoRelation
[];
autoFocus
?:
boolean
;
autoFocus
?:
boolean
;
onConfirm
?:
(
memo
Id
:
number
)
=>
void
;
onConfirm
?:
(
memo
Name
:
string
)
=>
void
;
onEditPrevious
?:
()
=>
void
;
onEditPrevious
?:
()
=>
void
;
}
}
...
@@ -50,7 +49,7 @@ interface State {
...
@@ -50,7 +49,7 @@ interface State {
}
}
const
MemoEditor
=
(
props
:
Props
)
=>
{
const
MemoEditor
=
(
props
:
Props
)
=>
{
const
{
className
,
editorClassName
,
cacheKey
,
memoId
,
parentMemoId
,
autoFocus
,
onConfirm
}
=
props
;
const
{
className
,
cacheKey
,
memoName
,
parentMemoName
,
autoFocus
,
onConfirm
}
=
props
;
const
{
i18n
}
=
useTranslation
();
const
{
i18n
}
=
useTranslation
();
const
t
=
useTranslate
();
const
t
=
useTranslate
();
const
{
const
{
...
@@ -74,12 +73,9 @@ const MemoEditor = (props: Props) => {
...
@@ -74,12 +73,9 @@ const MemoEditor = (props: Props) => {
const
userSetting
=
userStore
.
userSetting
as
UserSetting
;
const
userSetting
=
userStore
.
userSetting
as
UserSetting
;
const
contentCacheKey
=
`
${
currentUser
.
name
}
-
${
cacheKey
||
""
}
`
;
const
contentCacheKey
=
`
${
currentUser
.
name
}
-
${
cacheKey
||
""
}
`
;
const
[
contentCache
,
setContentCache
]
=
useLocalStorage
<
string
>
(
contentCacheKey
,
""
);
const
[
contentCache
,
setContentCache
]
=
useLocalStorage
<
string
>
(
contentCacheKey
,
""
);
const
referenceRelations
=
memo
Id
const
referenceRelations
=
memo
Name
?
state
.
relationList
.
filter
(
?
state
.
relationList
.
filter
(
(
relation
)
=>
(
relation
)
=>
relation
.
memo
===
memoName
&&
relation
.
relatedMemo
!==
memoName
&&
relation
.
type
===
MemoRelation_Type
.
REFERENCE
,
extractMemoIdFromName
(
relation
.
memo
)
===
memoId
&&
extractMemoIdFromName
(
relation
.
relatedMemo
)
!==
memoId
&&
relation
.
type
===
MemoRelation_Type
.
REFERENCE
,
)
)
:
state
.
relationList
.
filter
((
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
REFERENCE
);
:
state
.
relationList
.
filter
((
relation
)
=>
relation
.
type
===
MemoRelation_Type
.
REFERENCE
);
...
@@ -105,8 +101,8 @@ const MemoEditor = (props: Props) => {
...
@@ -105,8 +101,8 @@ const MemoEditor = (props: Props) => {
},
[
userSetting
.
memoVisibility
,
systemStatus
.
disablePublicMemos
]);
},
[
userSetting
.
memoVisibility
,
systemStatus
.
disablePublicMemos
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
memo
Id
)
{
if
(
memo
Name
)
{
memoStore
.
getOrFetchMemoByName
(
`
${
MemoNamePrefix
}${
memoId
}
`
).
then
((
memo
)
=>
{
memoStore
.
getOrFetchMemoByName
(
memoName
).
then
((
memo
)
=>
{
if
(
memo
)
{
if
(
memo
)
{
handleEditorFocus
();
handleEditorFocus
();
setState
((
prevState
)
=>
({
setState
((
prevState
)
=>
({
...
@@ -121,7 +117,7 @@ const MemoEditor = (props: Props) => {
...
@@ -121,7 +117,7 @@ const MemoEditor = (props: Props) => {
}
}
});
});
}
}
},
[
memo
Id
]);
},
[
memo
Name
]);
const
handleCompositionStart
=
()
=>
{
const
handleCompositionStart
=
()
=>
{
setState
((
prevState
)
=>
({
setState
((
prevState
)
=>
({
...
@@ -233,11 +229,11 @@ const MemoEditor = (props: Props) => {
...
@@ -233,11 +229,11 @@ const MemoEditor = (props: Props) => {
const
resource
=
await
handleUploadResource
(
file
);
const
resource
=
await
handleUploadResource
(
file
);
if
(
resource
)
{
if
(
resource
)
{
uploadedResourceList
.
push
(
resource
);
uploadedResourceList
.
push
(
resource
);
if
(
memo
Id
)
{
if
(
memo
Name
)
{
await
resourceStore
.
updateResource
({
await
resourceStore
.
updateResource
({
resource
:
Resource
.
fromPartial
({
resource
:
Resource
.
fromPartial
({
name
:
resource
.
name
,
name
:
resource
.
name
,
memoId
,
memoId
:
extractMemoIdFromName
(
memoName
)
,
}),
}),
updateMask
:
[
"memo_id"
],
updateMask
:
[
"memo_id"
],
});
});
...
@@ -296,8 +292,8 @@ const MemoEditor = (props: Props) => {
...
@@ -296,8 +292,8 @@ const MemoEditor = (props: Props) => {
const
content
=
editorRef
.
current
?.
getContent
()
??
""
;
const
content
=
editorRef
.
current
?.
getContent
()
??
""
;
try
{
try
{
// Update memo.
// Update memo.
if
(
memo
Id
&&
memoId
!==
UNKNOWN_ID
)
{
if
(
memo
Name
)
{
const
prevMemo
=
await
memoStore
.
getOrFetchMemoByName
(
`
${
MemoNamePrefix
}${
memoId
}
`
);
const
prevMemo
=
await
memoStore
.
getOrFetchMemoByName
(
memoName
);
if
(
prevMemo
)
{
if
(
prevMemo
)
{
const
memo
=
await
memoStore
.
updateMemo
(
const
memo
=
await
memoStore
.
updateMemo
(
{
{
...
@@ -315,22 +311,21 @@ const MemoEditor = (props: Props) => {
...
@@ -315,22 +311,21 @@ const MemoEditor = (props: Props) => {
name
:
memo
.
name
,
name
:
memo
.
name
,
relations
:
state
.
relationList
,
relations
:
state
.
relationList
,
});
});
const
memoId
=
extractMemoIdFromName
(
memo
.
name
);
await
memoStore
.
getOrFetchMemoByName
(
memo
.
name
,
{
skipCache
:
true
});
await
memoStore
.
getOrFetchMemoByName
(
`
${
MemoNamePrefix
}${
memoId
}
`
,
{
skipCache
:
true
});
if
(
onConfirm
)
{
if
(
onConfirm
)
{
onConfirm
(
memo
Id
);
onConfirm
(
memo
.
name
);
}
}
}
}
}
else
{
}
else
{
// Create memo or memo comment.
// Create memo or memo comment.
const
request
=
!
parentMemo
Id
const
request
=
!
parentMemo
Name
?
memoStore
.
createMemo
({
?
memoStore
.
createMemo
({
content
,
content
,
visibility
:
state
.
memoVisibility
,
visibility
:
state
.
memoVisibility
,
})
})
:
memoServiceClient
:
memoServiceClient
.
createMemoComment
({
.
createMemoComment
({
name
:
`
${
MemoNamePrefix
}${
parentMemoId
}
`
,
name
:
parentMemoName
,
comment
:
{
comment
:
{
content
,
content
,
visibility
:
state
.
memoVisibility
,
visibility
:
state
.
memoVisibility
,
...
@@ -346,10 +341,9 @@ const MemoEditor = (props: Props) => {
...
@@ -346,10 +341,9 @@ const MemoEditor = (props: Props) => {
name
:
memo
.
name
,
name
:
memo
.
name
,
relations
:
state
.
relationList
,
relations
:
state
.
relationList
,
});
});
const
memoId
=
extractMemoIdFromName
(
memo
.
name
);
await
memoStore
.
getOrFetchMemoByName
(
memo
.
name
,
{
skipCache
:
true
});
await
memoStore
.
getOrFetchMemoByName
(
`
${
MemoNamePrefix
}${
memoId
}
`
,
{
skipCache
:
true
});
if
(
onConfirm
)
{
if
(
onConfirm
)
{
onConfirm
(
memo
Id
);
onConfirm
(
memo
.
name
);
}
}
}
}
editorRef
.
current
?.
setContent
(
""
);
editorRef
.
current
?.
setContent
(
""
);
...
@@ -378,7 +372,7 @@ const MemoEditor = (props: Props) => {
...
@@ -378,7 +372,7 @@ const MemoEditor = (props: Props) => {
const
editorConfig
=
useMemo
(
const
editorConfig
=
useMemo
(
()
=>
({
()
=>
({
className
:
editorClassName
??
""
,
className
:
""
,
initialContent
:
""
,
initialContent
:
""
,
placeholder
:
t
(
"editor.placeholder"
),
placeholder
:
t
(
"editor.placeholder"
),
onContentChange
:
handleContentChange
,
onContentChange
:
handleContentChange
,
...
@@ -399,7 +393,7 @@ const MemoEditor = (props: Props) => {
...
@@ -399,7 +393,7 @@ const MemoEditor = (props: Props) => {
relationList
,
relationList
,
}));
}));
},
},
memo
Id
,
memo
Name
,
}
}
}
}
>
>
<
div
<
div
...
...
web/src/components/MemoEditor/types/context.ts
View file @
c7aaf791
...
@@ -4,8 +4,7 @@ import { MemoRelation } from "@/types/proto/api/v2/memo_relation_service";
...
@@ -4,8 +4,7 @@ import { MemoRelation } from "@/types/proto/api/v2/memo_relation_service";
interface
Context
{
interface
Context
{
relationList
:
MemoRelation
[];
relationList
:
MemoRelation
[];
setRelationList
:
(
relationList
:
MemoRelation
[])
=>
void
;
setRelationList
:
(
relationList
:
MemoRelation
[])
=>
void
;
// memoId is the id of the memo that is being edited.
memoName
?:
string
;
memoId
?:
number
;
}
}
export
const
MemoEditorContext
=
createContext
<
Context
>
({
export
const
MemoEditorContext
=
createContext
<
Context
>
({
...
...
web/src/components/MemoRelationListView.tsx
View file @
c7aaf791
...
@@ -63,7 +63,7 @@ const MemoRelationListView = (props: Props) => {
...
@@ -63,7 +63,7 @@ const MemoRelationListView = (props: Props) => {
<
div
key=
{
memo
.
name
}
className=
"block w-auto max-w-[50%]"
>
<
div
key=
{
memo
.
name
}
className=
"block w-auto max-w-[50%]"
>
<
Link
<
Link
className=
"px-2 border rounded-md w-auto text-sm leading-6 flex flex-row justify-start items-center flex-nowrap text-gray-600 dark:text-gray-400 dark:border-zinc-700 dark:bg-zinc-900 hover:shadow hover:opacity-80"
className=
"px-2 border rounded-md w-auto text-sm leading-6 flex flex-row justify-start items-center flex-nowrap text-gray-600 dark:text-gray-400 dark:border-zinc-700 dark:bg-zinc-900 hover:shadow hover:opacity-80"
to=
{
`/m/${memo.
name
}`
}
to=
{
`/m/${memo.
uid
}`
}
unstable_viewTransition
unstable_viewTransition
>
>
<
Tooltip
title=
"Backlink"
placement=
"top"
>
<
Tooltip
title=
"Backlink"
placement=
"top"
>
...
...
web/src/components/MemoView.tsx
View file @
c7aaf791
...
@@ -144,7 +144,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
...
@@ -144,7 +144,7 @@ const MemoView: React.FC<Props> = (props: Props) => {
</
div
>
</
div
>
<
MemoContent
<
MemoContent
key=
{
`${memo.name}-${memo.updateTime}`
}
key=
{
`${memo.name}-${memo.updateTime}`
}
memo
Id=
{
extractMemoIdFromName
(
memo
.
name
)
}
memo
Name=
{
memo
.
name
}
content=
{
memo
.
content
}
content=
{
memo
.
content
}
readonly=
{
readonly
}
readonly=
{
readonly
}
onClick=
{
handleMemoContentClick
}
onClick=
{
handleMemoContentClick
}
...
...
web/src/components/ShareMemoDialog.tsx
View file @
c7aaf791
...
@@ -155,7 +155,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
...
@@ -155,7 +155,7 @@ const ShareMemoDialog: React.FC<Props> = (props: Props) => {
>
>
<
span
className=
"w-full px-6 pt-5 pb-2 text-sm text-gray-500"
>
{
getDateTimeString
(
memo
.
displayTime
)
}
</
span
>
<
span
className=
"w-full px-6 pt-5 pb-2 text-sm text-gray-500"
>
{
getDateTimeString
(
memo
.
displayTime
)
}
</
span
>
<
div
className=
"w-full px-6 text-base pb-4 space-y-2"
>
<
div
className=
"w-full px-6 text-base pb-4 space-y-2"
>
<
MemoContent
memo
Id=
{
extractMemoIdFromName
(
memo
.
name
)
}
content=
{
memo
.
content
}
readonly=
{
true
}
disableFilter
/>
<
MemoContent
memo
Name=
{
memo
.
name
}
content=
{
memo
.
content
}
readonly=
{
true
}
disableFilter
/>
<
MemoResourceListView
resources=
{
memo
.
resources
}
/>
<
MemoResourceListView
resources=
{
memo
.
resources
}
/>
</
div
>
</
div
>
<
div
className=
"flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-900 py-4 px-6"
>
<
div
className=
"flex flex-row justify-between items-center w-full bg-gray-100 dark:bg-zinc-900 py-4 px-6"
>
...
...
web/src/pages/Archived.tsx
View file @
c7aaf791
...
@@ -99,7 +99,7 @@ const Archived = () => {
...
@@ -99,7 +99,7 @@ const Archived = () => {
<
MemoFilter
className=
"px-2 pb-2"
/>
<
MemoFilter
className=
"px-2 pb-2"
/>
{
sortedMemos
.
map
((
memo
)
=>
(
{
sortedMemos
.
map
((
memo
)
=>
(
<
div
<
div
key=
{
extractMemoIdFromName
(
memo
.
name
)
}
key=
{
memo
.
name
}
className=
"relative flex flex-col justify-start items-start w-full p-4 pt-3 mb-2 bg-white dark:bg-zinc-800 rounded-lg"
className=
"relative flex flex-col justify-start items-start w-full p-4 pt-3 mb-2 bg-white dark:bg-zinc-800 rounded-lg"
>
>
<
div
className=
"w-full mb-1 flex flex-row justify-between items-center"
>
<
div
className=
"w-full mb-1 flex flex-row justify-between items-center"
>
...
@@ -121,12 +121,7 @@ const Archived = () => {
...
@@ -121,12 +121,7 @@ const Archived = () => {
</
Tooltip
>
</
Tooltip
>
</
div
>
</
div
>
</
div
>
</
div
>
<
MemoContent
<
MemoContent
key=
{
`${memo.name}-${memo.displayTime}`
}
memoName=
{
memo
.
name
}
content=
{
memo
.
content
}
readonly=
{
true
}
/>
key=
{
`${memo.name}-${memo.displayTime}`
}
memoId=
{
extractMemoIdFromName
(
memo
.
name
)
}
content=
{
memo
.
content
}
readonly=
{
true
}
/>
</
div
>
</
div
>
))
}
))
}
{
isRequesting
?
(
{
isRequesting
?
(
...
...
web/src/pages/Home.tsx
View file @
c7aaf791
...
@@ -63,8 +63,8 @@ const Home = () => {
...
@@ -63,8 +63,8 @@ const Home = () => {
const
handleEditPrevious
=
useCallback
(()
=>
{
const
handleEditPrevious
=
useCallback
(()
=>
{
const
lastMemo
=
memoList
.
value
[
memoList
.
value
.
length
-
1
];
const
lastMemo
=
memoList
.
value
[
memoList
.
value
.
length
-
1
];
showMemoEditorDialog
({
showMemoEditorDialog
({
memo
Id
:
extractMemoIdFromName
(
lastMemo
.
name
)
,
memo
Name
:
lastMemo
.
name
,
cacheKey
:
`
${
lastMemo
.
name
}
-
${
lastMemo
.
update
Time
}
`
,
cacheKey
:
`
${
lastMemo
.
name
}
-
${
lastMemo
.
display
Time
}
`
,
});
});
},
[
memoList
]);
},
[
memoList
]);
...
...
web/src/pages/MemoDetail.tsx
View file @
c7aaf791
...
@@ -60,8 +60,8 @@ const MemoDetail = () => {
...
@@ -60,8 +60,8 @@ const MemoDetail = () => {
return
null
;
return
null
;
}
}
const
handleCommentCreated
=
async
(
commentId
:
number
)
=>
{
const
handleCommentCreated
=
async
(
memoCommentName
:
string
)
=>
{
await
memoStore
.
getOrFetchMemoByName
(
`
${
MemoNamePrefix
}${
commentId
}
`
);
await
memoStore
.
getOrFetchMemoByName
(
memoCommentName
);
await
memoStore
.
getOrFetchMemoByName
(
memo
.
name
,
{
skipCache
:
true
});
await
memoStore
.
getOrFetchMemoByName
(
memo
.
name
,
{
skipCache
:
true
});
};
};
...
@@ -117,7 +117,7 @@ const MemoDetail = () => {
...
@@ -117,7 +117,7 @@ const MemoDetail = () => {
<
MemoEditor
<
MemoEditor
key=
{
memo
.
name
}
key=
{
memo
.
name
}
cacheKey=
{
`comment-editor-${memo.name}`
}
cacheKey=
{
`comment-editor-${memo.name}`
}
parentMemo
Id=
{
extractMemoIdFromName
(
memo
.
name
)
}
parentMemo
Name=
{
memo
.
name
}
onConfirm=
{
handleCommentCreated
}
onConfirm=
{
handleCommentCreated
}
/>
/>
)
}
)
}
...
...
web/src/pages/Resources.tsx
View file @
c7aaf791
...
@@ -48,9 +48,9 @@ const Resources = () => {
...
@@ -48,9 +48,9 @@ const Resources = () => {
});
});
const
memoStore
=
useMemoStore
();
const
memoStore
=
useMemoStore
();
const
[
resources
,
setResources
]
=
useState
<
Resource
[]
>
([]);
const
[
resources
,
setResources
]
=
useState
<
Resource
[]
>
([]);
const
filteredResources
=
resources
.
filter
((
resource
:
any
)
=>
includes
(
resource
.
filename
,
state
.
searchQuery
));
const
filteredResources
=
resources
.
filter
((
resource
)
=>
includes
(
resource
.
filename
,
state
.
searchQuery
));
const
groupedResources
=
groupResourcesByDate
(
filteredResources
.
filter
((
resource
:
any
)
=>
resource
.
memoId
));
const
groupedResources
=
groupResourcesByDate
(
filteredResources
.
filter
((
resource
)
=>
resource
.
memoId
));
const
unusedResources
=
filteredResources
.
filter
((
resource
:
any
)
=>
!
resource
.
memoId
);
const
unusedResources
=
filteredResources
.
filter
((
resource
)
=>
!
resource
.
memoId
);
useEffect
(()
=>
{
useEffect
(()
=>
{
resourceServiceClient
.
listResources
({}).
then
(({
resources
})
=>
{
resourceServiceClient
.
listResources
({}).
then
(({
resources
})
=>
{
...
...
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