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
929f621b
Commit
929f621b
authored
Jun 24, 2022
by
boojack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: add image uploading status
parent
2c8ff279
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
16 deletions
+41
-16
MemoEditor.tsx
web/src/components/MemoEditor.tsx
+31
-15
editor.less
web/src/less/editor.less
+9
-1
setting-dialog.less
web/src/less/setting-dialog.less
+1
-0
No files found.
web/src/components/MemoEditor.tsx
View file @
929f621b
...
@@ -46,6 +46,7 @@ const MemoEditor: React.FC<Props> = () => {
...
@@ -46,6 +46,7 @@ const MemoEditor: React.FC<Props> = () => {
const
editorState
=
useAppSelector
((
state
)
=>
state
.
editor
);
const
editorState
=
useAppSelector
((
state
)
=>
state
.
editor
);
const
tags
=
useAppSelector
((
state
)
=>
state
.
memo
.
tags
);
const
tags
=
useAppSelector
((
state
)
=>
state
.
memo
.
tags
);
const
[
isTagSeletorShown
,
toggleTagSeletor
]
=
useToggle
(
false
);
const
[
isTagSeletorShown
,
toggleTagSeletor
]
=
useToggle
(
false
);
const
[
isUploadingResource
,
setIsUploadingResource
]
=
useToggle
(
false
);
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
editorRef
=
useRef
<
EditorRefActions
>
(
null
);
const
prevGlobalStateRef
=
useRef
(
editorState
);
const
prevGlobalStateRef
=
useRef
(
editorState
);
const
tagSeletorRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
tagSeletorRef
=
useRef
<
HTMLDivElement
>
(
null
);
...
@@ -119,7 +120,13 @@ const MemoEditor: React.FC<Props> = () => {
...
@@ -119,7 +120,13 @@ const MemoEditor: React.FC<Props> = () => {
};
};
},
[]);
},
[]);
const
handleUploadFile
=
useCallback
(
async
(
file
:
File
)
=>
{
const
handleUploadFile
=
useCallback
(
async
(
file
:
File
)
=>
{
if
(
isUploadingResource
)
{
return
;
}
setIsUploadingResource
(
true
);
const
{
type
}
=
file
;
const
{
type
}
=
file
;
if
(
!
type
.
startsWith
(
"image"
))
{
if
(
!
type
.
startsWith
(
"image"
))
{
...
@@ -133,8 +140,12 @@ const MemoEditor: React.FC<Props> = () => {
...
@@ -133,8 +140,12 @@ const MemoEditor: React.FC<Props> = () => {
return
url
;
return
url
;
}
catch
(
error
:
any
)
{
}
catch
(
error
:
any
)
{
toastHelper
.
error
(
error
);
toastHelper
.
error
(
error
);
}
finally
{
setIsUploadingResource
(
false
);
}
}
},
[]);
},
[
isUploadingResource
]
);
const
handleSaveBtnClick
=
useCallback
(
async
(
content
:
string
)
=>
{
const
handleSaveBtnClick
=
useCallback
(
async
(
content
:
string
)
=>
{
if
(
content
===
""
)
{
if
(
content
===
""
)
{
...
@@ -283,8 +294,13 @@ const MemoEditor: React.FC<Props> = () => {
...
@@ -283,8 +294,13 @@ const MemoEditor: React.FC<Props> = () => {
{
...
editorConfig
}
{
...
editorConfig
}
tools=
{
tools=
{
<>
<>
<
img
className=
"action-btn file-upload"
src=
"/icons/tag.svg"
onClick=
{
handleTagTextBtnClick
}
/>
<
div
className=
"action-btn"
>
<
img
className=
"action-btn file-upload"
src=
"/icons/image.svg"
onClick=
{
handleUploadFileBtnClick
}
/>
<
img
className=
"icon-img"
src=
"/icons/tag.svg"
onClick=
{
handleTagTextBtnClick
}
/>
</
div
>
<
div
className=
"action-btn"
>
<
img
className=
"icon-img"
src=
"/icons/image.svg"
onClick=
{
handleUploadFileBtnClick
}
/>
<
span
className=
{
`tip-text ${isUploadingResource ? "!block" : ""}`
}
>
Uploading
</
span
>
</
div
>
</>
</>
}
}
/>
/>
...
...
web/src/less/editor.less
View file @
929f621b
...
@@ -29,7 +29,15 @@
...
@@ -29,7 +29,15 @@
@apply flex flex-row justify-start items-center;
@apply flex flex-row justify-start items-center;
> .action-btn {
> .action-btn {
@apply p-1 w-7 h-auto mr-1 select-none rounded cursor-pointer opacity-60 hover:opacity-80 hover:bg-gray-300 hover:shadow;
@apply flex flex-row justify-start items-center p-1 w-auto h-auto mr-1 select-none rounded cursor-pointer opacity-60 hover:opacity-80 hover:bg-gray-300 hover:shadow;
> .icon-img {
@apply w-5 h-auto;
}
> .tip-text {
@apply hidden ml-1 text-xs leading-5 text-gray-700 border border-gray-300 rounded-xl px-2;
}
}
}
}
}
...
...
web/src/less/setting-dialog.less
View file @
929f621b
...
@@ -42,6 +42,7 @@
...
@@ -42,6 +42,7 @@
> .section-content-container {
> .section-content-container {
@apply w-full sm:w-auto p-4 sm:px-6 grow flex flex-col justify-start items-start h-128 overflow-y-scroll;
@apply w-full sm:w-auto p-4 sm:px-6 grow flex flex-col justify-start items-start h-128 overflow-y-scroll;
.hide-scroll-bar();
> .section-container {
> .section-container {
.flex(column, flex-start, flex-start);
.flex(column, flex-start, flex-start);
...
...
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