({ anchor })
| 38 | export const getStyle: PlasmoGetStyle = () => TagBtnStyle() |
| 39 | |
| 40 | const PlasmoOverlay: FC<PlasmoCSUIProps> = ({ anchor }) => { |
| 41 | const [parseContent, setParseContent] = useParseMarkdown() |
| 42 | const [allShowTag, setAllShowTag] = useStorage("config-allShowTag", true) |
| 43 | const [showTag, setShowTag] = useStorage<boolean>("php-showTag", true) |
| 44 | const [cssCode, runCss] = useCssCodeHook("php") |
| 45 | const [copyCode] = useStorage("php-copyCode", true) |
| 46 | const [closeLoginModal] = useStorage<boolean>("php-closeLoginModal") |
| 47 | const [history, setHistory] = useStorage<any[]>("codebox-history") |
| 48 | const [closeLog] = useStorage("config-closeLog", true) |
| 49 | const [content, setContent] = useEditMarkdown() |
| 50 | |
| 51 | useEffect(() => { |
| 52 | closeLog || console.log("PHP status", { closeLoginModal }) |
| 53 | copyCodeFunc(copyCode) |
| 54 | closeLoginModal && closeLoginModalFunc() |
| 55 | }, [closeLoginModal]) |
| 56 | |
| 57 | useMessage(async (req, res) => { |
| 58 | if (req.name == "php-isShow") { |
| 59 | res.send({ isShow: true }) |
| 60 | } |
| 61 | if (req.name == "php-editMarkdown") { |
| 62 | editMarkdown() |
| 63 | } |
| 64 | if (req.name == "php-downloadMarkdown") { |
| 65 | downloadMarkdown() |
| 66 | } |
| 67 | if (req.name == "php-downloadHtml") { |
| 68 | downloadHtml() |
| 69 | } |
| 70 | if (req.name == "oschina-downloadPdf") { |
| 71 | downloadPdf() |
| 72 | } |
| 73 | }) |
| 74 | |
| 75 | function downloadPdf() { |
| 76 | const article = document.querySelector<HTMLElement>( |
| 77 | ".phpscMain .php-article" |
| 78 | ) |
| 79 | if (article) { |
| 80 | Print.print(article, { title: articleTitle }) |
| 81 | .then(() => console.log("Printing complete")) |
| 82 | .catch((error) => console.error("Printing failed:", error)) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | function downloadWord() { |
| 87 | const dom = document.querySelector(".phpscMain .php-article") |
| 88 | saveWord(dom, articleTitle) |
| 89 | } |
| 90 | |
| 91 | /* 未登录复制代码 */ |
| 92 | function copyCodeCssFunc(copyCode) { |
| 93 | copyCode |
| 94 | ? addCss( |
| 95 | ` |
| 96 | .php-article .code, |
| 97 | .php-article{ |
nothing calls this directly
no test coverage detected