()
| 98 | export const getShadowHostId: PlasmoGetShadowHostId = () => "codebox-medium" |
| 99 | |
| 100 | const PlasmoOverlay: FC<PlasmoCSUIProps> = () => { |
| 101 | const [parseContent, setParseContent] = useParseMarkdown() |
| 102 | const [allShowTag, setAllShowTag] = useStorage("config-allShowTag", true) |
| 103 | const [showTag, setShowTag] = useStorage<boolean>("medium-showTag", true) |
| 104 | const [cssCode, runCss] = useCssCodeHook("medium") |
| 105 | const [content, setContent] = useEditMarkdown(turndownOption) |
| 106 | |
| 107 | useMessage(async (req, res) => { |
| 108 | switch (req.name) { |
| 109 | case "medium-isShow": |
| 110 | res.send({ isShow: true }) |
| 111 | break |
| 112 | case "medium-editMarkdown": |
| 113 | editMarkdown() |
| 114 | break |
| 115 | case "medium-downloadMarkdown": |
| 116 | downloadMarkdown() |
| 117 | break |
| 118 | case "medium-downloadHtml": |
| 119 | downloadHtml() |
| 120 | break |
| 121 | case "medium-downloadPdf": |
| 122 | downloadPdf() |
| 123 | break |
| 124 | } |
| 125 | }) |
| 126 | |
| 127 | function getDescription() { |
| 128 | const summary = document.querySelector<HTMLMetaElement>( |
| 129 | 'meta[name="description"]' |
| 130 | ).content |
| 131 | summary && prompt(i18n("getDescription"), summary) |
| 132 | } |
| 133 | |
| 134 | function downloadPdf() { |
| 135 | const article = document.querySelector<HTMLElement>("article") |
| 136 | if (article) { |
| 137 | Print.print(article, { title: articleTitle }) |
| 138 | .then(() => console.log("Printing complete")) |
| 139 | .catch((error) => console.error("Printing failed:", error)) |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | function downloadWord() { |
| 144 | const dom = document.querySelector("article") |
| 145 | saveWord(dom, articleTitle) |
| 146 | } |
| 147 | |
| 148 | function editMarkdown() { |
| 149 | const dom = document.querySelector("article") |
| 150 | setContent(dom, articleTitle) |
| 151 | } |
| 152 | |
| 153 | function downloadMarkdown() { |
| 154 | const html = document.querySelector("article") |
| 155 | const markdown = turndownService.turndown(html) |
| 156 | saveMarkdown(markdown, articleTitle) |
| 157 | } |
nothing calls this directly
no test coverage detected