docs: bug fixes for copy and color mode (#8626)
* docs: bug fixes for copy and color mode * remove unused dependency
This commit is contained in:
@@ -67,7 +67,6 @@
|
||||
"@segment/analytics-next": "^1.55.0",
|
||||
"@uidotdev/usehooks": "^2.4.1",
|
||||
"algoliasearch": "^4.20.0",
|
||||
"copy-text-to-clipboard": "^3.2.0",
|
||||
"framer-motion": "^11.3.21",
|
||||
"mermaid": "^10.9.0",
|
||||
"npm-to-yarn": "^2.1.0",
|
||||
|
||||
@@ -46,7 +46,7 @@ export const Sidebar = ({
|
||||
})
|
||||
useKeyboardShortcut({
|
||||
metakey: true,
|
||||
shortcutKeys: ["."],
|
||||
shortcutKeys: ["\\"],
|
||||
action: () => {
|
||||
setDesktopSidebarOpen((prev) => !prev)
|
||||
},
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use client"
|
||||
|
||||
import { useCallback, useEffect, useRef, useState } from "react"
|
||||
import copy from "copy-text-to-clipboard"
|
||||
|
||||
type useCopyReturnType = {
|
||||
isCopied: boolean
|
||||
@@ -13,11 +12,15 @@ export const useCopy = (text: string): useCopyReturnType => {
|
||||
const copyTimeout = useRef<number>(0)
|
||||
|
||||
const handleCopy = useCallback(() => {
|
||||
copy(text)
|
||||
setIsCopied(true)
|
||||
copyTimeout.current = window.setTimeout(() => {
|
||||
setIsCopied(false)
|
||||
}, 1000)
|
||||
navigator.clipboard
|
||||
.writeText(text.trim())
|
||||
.then(() => {
|
||||
setIsCopied(true)
|
||||
copyTimeout.current = window.setTimeout(() => {
|
||||
setIsCopied(false)
|
||||
}, 1000)
|
||||
})
|
||||
.catch(console.error)
|
||||
}, [text])
|
||||
|
||||
useEffect(() => () => window.clearTimeout(copyTimeout.current), [])
|
||||
|
||||
@@ -31,8 +31,8 @@ export const ColorModeProvider = ({ children }: ColorModeProviderProps) => {
|
||||
const theme = localStorage.getItem("theme")
|
||||
if (theme && (theme === "light" || theme === "dark")) {
|
||||
setColorMode(theme)
|
||||
setLoaded(true)
|
||||
}
|
||||
setLoaded(true)
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -6510,13 +6510,6 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"copy-text-to-clipboard@npm:^3.2.0":
|
||||
version: 3.2.0
|
||||
resolution: "copy-text-to-clipboard@npm:3.2.0"
|
||||
checksum: d60fdadc59d526e19d56ad23cec2b292d33c771a5091621bd322d138804edd3c10eb2367d46ec71b39f5f7f7116a2910b332281aeb36a5b679199d746a8a5381
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"copy-to-clipboard@npm:^3.3.3":
|
||||
version: 3.3.3
|
||||
resolution: "copy-to-clipboard@npm:3.3.3"
|
||||
@@ -7264,7 +7257,6 @@ __metadata:
|
||||
"@uidotdev/usehooks": ^2.4.1
|
||||
algoliasearch: ^4.20.0
|
||||
clsx: ^2.0.0
|
||||
copy-text-to-clipboard: ^3.2.0
|
||||
cpy-cli: ^5.0.0
|
||||
eslint: ^8
|
||||
eslint-config-docs: "*"
|
||||
|
||||
Reference in New Issue
Block a user