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
c5b26e33
Unverified
Commit
c5b26e33
authored
Sep 14, 2022
by
boojack
Committed by
GitHub
Sep 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chore: fix copy to clipboard (#214)
parent
7079faf2
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
16 deletions
+15
-16
package.json
web/package.json
+1
-0
ResourcesDialog.tsx
web/src/components/ResourcesDialog.tsx
+2
-2
TagList.tsx
web/src/components/TagList.tsx
+0
-2
utils.ts
web/src/helpers/utils.ts
+0
-12
yarn.lock
web/yarn.lock
+12
-0
No files found.
web/package.json
View file @
c5b26e33
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
"dependencies"
:
{
"dependencies"
:
{
"@reduxjs/toolkit"
:
"^1.8.1"
,
"@reduxjs/toolkit"
:
"^1.8.1"
,
"axios"
:
"^0.27.2"
,
"axios"
:
"^0.27.2"
,
"copy-to-clipboard"
:
"^3.3.2"
,
"dayjs"
:
"^1.11.3"
,
"dayjs"
:
"^1.11.3"
,
"lodash-es"
:
"^4.17.21"
,
"lodash-es"
:
"^4.17.21"
,
"qs"
:
"^6.11.0"
,
"qs"
:
"^6.11.0"
,
...
...
web/src/components/ResourcesDialog.tsx
View file @
c5b26e33
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
*
as
utils
from
"../helpers/utils
"
;
import
copy
from
"copy-to-clipboard
"
;
import
useI18n
from
"../hooks/useI18n"
;
import
useI18n
from
"../hooks/useI18n"
;
import
useLoading
from
"../hooks/useLoading"
;
import
useLoading
from
"../hooks/useLoading"
;
import
{
resourceService
}
from
"../services"
;
import
{
resourceService
}
from
"../services"
;
...
@@ -99,7 +99,7 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
...
@@ -99,7 +99,7 @@ const ResourcesDialog: React.FC<Props> = (props: Props) => {
};
};
const
handleCopyResourceLinkBtnClick
=
(
resource
:
Resource
)
=>
{
const
handleCopyResourceLinkBtnClick
=
(
resource
:
Resource
)
=>
{
utils
.
copyTextToClipboard
(
`
${
window
.
location
.
origin
}
/o/r/
${
resource
.
id
}
/
${
resource
.
filename
}
`
);
copy
(
`
${
window
.
location
.
origin
}
/o/r/
${
resource
.
id
}
/
${
resource
.
filename
}
`
);
toastHelper
.
success
(
"Succeed to copy resource link to clipboard"
);
toastHelper
.
success
(
"Succeed to copy resource link to clipboard"
);
};
};
...
...
web/src/components/TagList.tsx
View file @
c5b26e33
import
{
useEffect
,
useState
}
from
"react"
;
import
{
useEffect
,
useState
}
from
"react"
;
import
*
as
utils
from
"../helpers/utils"
;
import
{
useAppSelector
}
from
"../store"
;
import
{
useAppSelector
}
from
"../store"
;
import
{
locationService
,
memoService
,
userService
}
from
"../services"
;
import
{
locationService
,
memoService
,
userService
}
from
"../services"
;
import
useI18n
from
"../hooks/useI18n"
;
import
useI18n
from
"../hooks/useI18n"
;
...
@@ -97,7 +96,6 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
...
@@ -97,7 +96,6 @@ const TagItemContainer: React.FC<TagItemContainerProps> = (props: TagItemContain
if
(
isActive
)
{
if
(
isActive
)
{
locationService
.
setTagQuery
(
undefined
);
locationService
.
setTagQuery
(
undefined
);
}
else
{
}
else
{
utils
.
copyTextToClipboard
(
`#
${
tag
.
text
}
`
);
locationService
.
setTagQuery
(
tag
.
text
);
locationService
.
setTagQuery
(
tag
.
text
);
}
}
};
};
...
...
web/src/helpers/utils.ts
View file @
c5b26e33
...
@@ -147,18 +147,6 @@ export function filterObjectNullKeys(object: KVObject): KVObject {
...
@@ -147,18 +147,6 @@ export function filterObjectNullKeys(object: KVObject): KVObject {
return
finalObject
;
return
finalObject
;
}
}
export
async
function
copyTextToClipboard
(
text
:
string
)
{
if
(
navigator
.
clipboard
&&
navigator
.
clipboard
.
writeText
)
{
try
{
await
navigator
.
clipboard
.
writeText
(
text
);
}
catch
(
error
:
unknown
)
{
console
.
warn
(
"Copy to clipboard failed."
,
error
);
}
}
else
{
console
.
warn
(
"Copy to clipboard failed, methods not supports."
);
}
}
export
function
getImageSize
(
src
:
string
):
Promise
<
{
width
:
number
;
height
:
number
}
>
{
export
function
getImageSize
(
src
:
string
):
Promise
<
{
width
:
number
;
height
:
number
}
>
{
return
new
Promise
((
resolve
)
=>
{
return
new
Promise
((
resolve
)
=>
{
const
imgEl
=
new
Image
();
const
imgEl
=
new
Image
();
...
...
web/yarn.lock
View file @
c5b26e33
...
@@ -767,6 +767,13 @@ copy-anything@^2.0.1:
...
@@ -767,6 +767,13 @@ copy-anything@^2.0.1:
dependencies:
dependencies:
is-what "^3.14.1"
is-what "^3.14.1"
copy-to-clipboard@^3.3.2:
version "3.3.2"
resolved "https://registry.yarnpkg.com/copy-to-clipboard/-/copy-to-clipboard-3.3.2.tgz#5b263ec2366224b100181dded7ce0579b340c107"
integrity sha512-Vme1Z6RUDzrb6xAI7EZlVZ5uvOk2F//GaxKUxajDqm9LhOVM1inxNAD2vy+UZDYsd0uyA9s7b3/FVZPSxqrCfg==
dependencies:
toggle-selection "^1.0.6"
cross-spawn@^7.0.2:
cross-spawn@^7.0.2:
version "7.0.3"
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
...
@@ -2400,6 +2407,11 @@ to-regex-range@^5.0.1:
...
@@ -2400,6 +2407,11 @@ to-regex-range@^5.0.1:
dependencies:
dependencies:
is-number "^7.0.0"
is-number "^7.0.0"
toggle-selection@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/toggle-selection/-/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"
integrity sha512-BiZS+C1OS8g/q2RRbJmy59xpyghNBqrr6k5L/uKBGRsTfxmu3ffiRnd8mlGPUVayg8pvfi5urfnu8TU7DVOkLQ==
tslib@^1.8.1:
tslib@^1.8.1:
version "1.14.1"
version "1.14.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
...
...
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