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
39bf8505
Commit
39bf8505
authored
Feb 22, 2024
by
Steven
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: embed memos callback
parent
9cd835b9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
11 deletions
+5
-11
CreateMemoRelationDialog.tsx
web/src/components/CreateMemoRelationDialog.tsx
+2
-5
AddMemoRelationButton.tsx
...ponents/MemoEditor/ActionButton/AddMemoRelationButton.tsx
+3
-6
No files found.
web/src/components/CreateMemoRelationDialog.tsx
View file @
39bf8505
...
...
@@ -12,7 +12,7 @@ import { generateDialog } from "./Dialog";
import
Icon
from
"./Icon"
;
interface
Props
extends
DialogProps
{
onConfirm
:
(
memo
IdList
:
number
[],
embedded
?:
boolean
)
=>
void
;
onConfirm
:
(
memo
s
:
Memo
[],
embedded
?:
boolean
)
=>
void
;
}
const
CreateMemoRelationDialog
:
React
.
FC
<
Props
>
=
(
props
:
Props
)
=>
{
...
...
@@ -78,10 +78,7 @@ const CreateMemoRelationDialog: React.FC<Props> = (props: Props) => {
};
const
handleConfirmBtnClick
=
async
()
=>
{
onConfirm
(
selectedMemos
.
map
((
memo
)
=>
memo
.
id
),
embedded
,
);
onConfirm
(
selectedMemos
,
embedded
);
destroy
();
};
...
...
web/src/components/MemoEditor/ActionButton/AddMemoRelationButton.tsx
View file @
39bf8505
...
...
@@ -5,7 +5,6 @@ import toast from "react-hot-toast";
import
showCreateMemoRelationDialog
from
"@/components/CreateMemoRelationDialog"
;
import
Icon
from
"@/components/Icon"
;
import
{
UNKNOWN_ID
}
from
"@/helpers/consts"
;
import
{
useMemoStore
}
from
"@/store/v1"
;
import
{
MemoRelation_Type
}
from
"@/types/proto/api/v2/memo_relation_service"
;
import
{
EditorRefActions
}
from
"../Editor"
;
import
{
MemoEditorContext
}
from
"../types"
;
...
...
@@ -16,12 +15,11 @@ interface Props {
const
AddMemoRelationButton
=
(
props
:
Props
)
=>
{
const
{
editorRef
}
=
props
;
const
memoStore
=
useMemoStore
();
const
context
=
useContext
(
MemoEditorContext
);
const
handleAddMemoRelationBtnClick
=
()
=>
{
showCreateMemoRelationDialog
({
onConfirm
:
(
memo
IdList
,
embedded
)
=>
{
onConfirm
:
(
memo
s
,
embedded
)
=>
{
// If embedded mode is enabled, embed the memo instead of creating a relation.
if
(
embedded
)
{
if
(
!
editorRef
.
current
)
{
...
...
@@ -34,8 +32,7 @@ const AddMemoRelationButton = (props: Props) => {
if
(
prevValue
!==
""
&&
!
prevValue
.
endsWith
(
"
\n
"
))
{
editorRef
.
current
.
insertText
(
"
\n
"
);
}
for
(
const
memoId
of
memoIdList
)
{
const
memo
=
memoStore
.
getMemoById
(
memoId
);
for
(
const
memo
of
memos
)
{
editorRef
.
current
.
insertText
(
`![[memos/
${
memo
.
name
}
]]\n`
);
}
setTimeout
(()
=>
{
...
...
@@ -48,7 +45,7 @@ const AddMemoRelationButton = (props: Props) => {
context
.
setRelationList
(
uniqBy
(
[
...
memo
IdList
.
map
((
id
)
=>
({
memoId
:
context
.
memoId
||
UNKNOWN_ID
,
relatedMemoId
:
id
,
type
:
MemoRelation_Type
.
REFERENCE
})),
...
memo
s
.
map
((
memo
)
=>
({
memoId
:
context
.
memoId
||
UNKNOWN_ID
,
relatedMemoId
:
memo
.
id
,
type
:
MemoRelation_Type
.
REFERENCE
})),
...
context
.
relationList
,
].
filter
((
relation
)
=>
relation
.
relatedMemoId
!==
(
context
.
memoId
||
UNKNOWN_ID
)),
"relatedMemoId"
,
...
...
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