()
| 31 | export const getShadowHostId: PlasmoGetShadowHostId = () => "codebox-pianshen" |
| 32 | |
| 33 | const PlasmoOverlay: FC<PlasmoCSUIProps> = () => { |
| 34 | const [parseContent, setParseContent] = useParseMarkdown() |
| 35 | const [allShowTag, setAllShowTag] = useStorage("config-allShowTag", true) |
| 36 | const [showTag, setShowTag] = useStorage<boolean>("pianshen-showTag", true) |
| 37 | const [cssCode, runCss] = useCssCodeHook("pianshen") |
| 38 | const [content, setContent] = useEditMarkdown() |
| 39 | |
| 40 | useMessage(async (req, res) => { |
| 41 | if (req.name == "pianshen-isShow") { |
| 42 | res.send({ isShow: true }) |
| 43 | } |
| 44 | if (req.name == "pianshen-editMarkdown") { |
| 45 | editMarkdown() |
| 46 | } |
| 47 | if (req.name == "pianshen-downloadMarkdown") { |
| 48 | downloadMarkdown() |
| 49 | } |
| 50 | if (req.name == "pianshen-downloadHtml") { |
| 51 | downloadHtml() |
| 52 | } |
| 53 | if (req.name == "pianshen-downloadPdf") { |
| 54 | downloadPdf() |
| 55 | } |
| 56 | }) |
| 57 | |
| 58 | function getDescription() { |
| 59 | const summary = document.querySelector<HTMLMetaElement>( |
| 60 | 'meta[name="description"]' |
| 61 | ).content |
| 62 | summary && prompt(i18n("getDescription"), summary) |
| 63 | } |
| 64 | |
| 65 | function downloadPdf() { |
| 66 | const article = document.querySelector<HTMLElement>("#article_content") |
| 67 | if (article) { |
| 68 | Print.print(article, { title: articleTitle }) |
| 69 | .then(() => console.log("Printing complete")) |
| 70 | .catch((error) => console.error("Printing failed:", error)) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | function downloadWord() { |
| 75 | const dom = document.querySelector("#article_content") |
| 76 | saveWord(dom, articleTitle) |
| 77 | } |
| 78 | |
| 79 | function editMarkdown() { |
| 80 | const dom = document.querySelector("#article_content") |
| 81 | setContent(dom, articleTitle) |
| 82 | } |
| 83 | |
| 84 | function downloadMarkdown() { |
| 85 | const html = document.querySelector("#article_content") |
| 86 | const markdown = turndownService.turndown(html) |
| 87 | saveMarkdown(markdown, articleTitle) |
| 88 | } |
| 89 | |
| 90 | function downloadHtml() { |
nothing calls this directly
no test coverage detected