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