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
3b089eea
Unverified
Commit
3b089eea
authored
Mar 03, 2024
by
jjaychen
Committed by
GitHub
Mar 03, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: ignore "Tab" key down event when is composing in editor(#3026) (#3027)
parent
9a8a1d01
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
index.tsx
web/src/components/MemoEditor/index.tsx
+19
-1
No files found.
web/src/components/MemoEditor/index.tsx
View file @
3b089eea
...
@@ -45,6 +45,7 @@ interface State {
...
@@ -45,6 +45,7 @@ interface State {
relationList
:
MemoRelation
[];
relationList
:
MemoRelation
[];
isUploadingResource
:
boolean
;
isUploadingResource
:
boolean
;
isRequesting
:
boolean
;
isRequesting
:
boolean
;
isComposing
:
boolean
;
}
}
const
MemoEditor
=
(
props
:
Props
)
=>
{
const
MemoEditor
=
(
props
:
Props
)
=>
{
...
@@ -65,6 +66,7 @@ const MemoEditor = (props: Props) => {
...
@@ -65,6 +66,7 @@ const MemoEditor = (props: Props) => {
relationList
:
props
.
relationList
??
[],
relationList
:
props
.
relationList
??
[],
isUploadingResource
:
false
,
isUploadingResource
:
false
,
isRequesting
:
false
,
isRequesting
:
false
,
isComposing
:
false
,
});
});
const
[
hasContent
,
setHasContent
]
=
useState
<
boolean
>
(
false
);
const
[
hasContent
,
setHasContent
]
=
useState
<
boolean
>
(
false
);
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
...
@@ -117,6 +119,20 @@ const MemoEditor = (props: Props) => {
...
@@ -117,6 +119,20 @@ const MemoEditor = (props: Props) => {
}
}
},
[
memoId
]);
},
[
memoId
]);
const
handleCompositionStart
=
()
=>
{
setState
((
prevState
)
=>
({
...
prevState
,
isComposing
:
true
,
}));
};
const
handleCompositionEnd
=
()
=>
{
setState
((
prevState
)
=>
({
...
prevState
,
isComposing
:
false
,
}));
};
const
handleKeyDown
=
(
event
:
React
.
KeyboardEvent
)
=>
{
const
handleKeyDown
=
(
event
:
React
.
KeyboardEvent
)
=>
{
if
(
!
editorRef
.
current
)
{
if
(
!
editorRef
.
current
)
{
return
;
return
;
...
@@ -131,7 +147,7 @@ const MemoEditor = (props: Props) => {
...
@@ -131,7 +147,7 @@ const MemoEditor = (props: Props) => {
handleEditorKeydownWithMarkdownShortcuts
(
event
,
editorRef
.
current
);
handleEditorKeydownWithMarkdownShortcuts
(
event
,
editorRef
.
current
);
}
}
if
(
event
.
key
===
"Tab"
)
{
if
(
event
.
key
===
"Tab"
&&
!
state
.
isComposing
)
{
event
.
preventDefault
();
event
.
preventDefault
();
const
tabSpace
=
" "
.
repeat
(
TAB_SPACE_WIDTH
);
const
tabSpace
=
" "
.
repeat
(
TAB_SPACE_WIDTH
);
const
cursorPosition
=
editorRef
.
current
.
getCursorPosition
();
const
cursorPosition
=
editorRef
.
current
.
getCursorPosition
();
...
@@ -382,6 +398,8 @@ const MemoEditor = (props: Props) => {
...
@@ -382,6 +398,8 @@ const MemoEditor = (props: Props) => {
onKeyDown=
{
handleKeyDown
}
onKeyDown=
{
handleKeyDown
}
onDrop=
{
handleDropEvent
}
onDrop=
{
handleDropEvent
}
onFocus=
{
handleEditorFocus
}
onFocus=
{
handleEditorFocus
}
onCompositionStart=
{
handleCompositionStart
}
onCompositionEnd=
{
handleCompositionEnd
}
>
>
<
Editor
ref=
{
editorRef
}
{
...
editorConfig
}
/>
<
Editor
ref=
{
editorRef
}
{
...
editorConfig
}
/>
<
ResourceListView
resourceList=
{
state
.
resourceList
}
setResourceList=
{
handleSetResourceList
}
/>
<
ResourceListView
resourceList=
{
state
.
resourceList
}
setResourceList=
{
handleSetResourceList
}
/>
...
...
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