MCPcopy
hub / github.com/027xiguapi/code-box / PlasmoOverlay

Function PlasmoOverlay

contents/jianshu.tsx:41–233  ·  view source on GitHub ↗
({ anchor })

Source from the content-addressed store, hash-verified

39export const getStyle: PlasmoGetStyle = () => TagBtnStyle()
40
41const PlasmoOverlay: FC<PlasmoCSUIProps> = ({ anchor }) => {
42 const [parseContent, setParseContent] = useParseMarkdown()
43 const [allShowTag, setAllShowTag] = useStorage("config-allShowTag", true)
44 const [showTag, setShowTag] = useStorage<boolean>("jianshu-showTag", true)
45 const [cssCode, runCss] = useCssCodeHook("jianshu")
46 const [closeLoginModal] = useStorage<boolean>("jianshu-closeLoginModal")
47 const [copyCode] = useStorage<boolean>("jianshu-copyCode")
48 const [autoOpenCode] = useStorage<boolean>("jianshu-autoOpenCode")
49 const [history, setHistory] = useStorage<any[]>("codebox-history")
50 const [closeLog] = useStorage("config-closeLog", true)
51 const [content, setContent] = useEditMarkdown()
52
53 useEffect(() => {
54 closeLog ||
55 console.log("jianshu status", { copyCode, closeLoginModal, autoOpenCode })
56 copyCode && copyCodeFunc()
57 closeLoginModal && closeLoginModalFunc()
58 autoOpenCode && autoOpenCodeFunc()
59 }, [copyCode, closeLoginModal, autoOpenCode])
60
61 useMessage(async (req, res) => {
62 if (req.name == "jianshu-isShow") {
63 res.send({ isShow: true })
64 }
65 if (req.name == "jianshu-editMarkdown") {
66 editMarkdown()
67 }
68 if (req.name == "jianshu-downloadMarkdown") {
69 downloadMarkdown()
70 }
71 if (req.name == "jianshu-downloadHtml") {
72 downloadHtml()
73 }
74 if (req.name == "jianshu-downloadPdf") {
75 downloadPdf()
76 }
77 })
78
79 // 一键复制
80 function copyCodeFunc() {
81 const codes = document.querySelectorAll<HTMLElement>(".hljs")
82
83 codes.forEach((code) => {
84 const button = document.createElement("button")
85 button.innerText = i18n("copy")
86 button.style.position = "absolute"
87 button.style.top = "0"
88 button.style.right = "0"
89 button.style.background = "#fff"
90 button.title = i18n("copyCode")
91 button.classList.add("Button")
92 button.classList.add("VoteButton")
93
94 code.appendChild(button)
95 code.style.position = "relative"
96
97 button.addEventListener("click", (e) => {
98 const target = e.target as HTMLElement

Callers

nothing calls this directly

Calls 11

useParseMarkdownFunction · 0.90
useEditMarkdownFunction · 0.90
useCssCodeHookFunction · 0.85
sendMethod · 0.80
copyCodeFuncFunction · 0.70
closeLoginModalFuncFunction · 0.70
autoOpenCodeFuncFunction · 0.70
editMarkdownFunction · 0.70
downloadMarkdownFunction · 0.70
downloadHtmlFunction · 0.70
downloadPdfFunction · 0.70

Tested by

no test coverage detected