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

Function useParseMarkdown

utils/parseMarkdownHook.ts:6–40  ·  view source on GitHub ↗
(option?)

Source from the content-addressed store, hash-verified

4import Turndown from "~utils/turndown"
5
6export function useParseMarkdown(option?) {
7 const turndownService = Turndown(option)
8
9 const [aiContent, setAiContent] = useStorage({
10 key: "ai-content",
11 instance: new Storage({
12 area: "local"
13 })
14 })
15
16 const [aiType, setAiType] = useStorage("app-aiType")
17
18 const handleSetContent = (selectorDom, type?) => {
19 let markdown = turndownService.turndown(selectorDom)
20 markdown = `${markdown}
21 将上面的文字,翻译成中文并生成markdown`
22
23 setAiContent(markdown)
24 type = type || aiType
25
26 switch (type) {
27 case "kimi":
28 window.open("https://kimi.moonshot.cn/", "_blank")
29 break
30 case "chatgpt":
31 window.open("https://chatgpt.com", "_blank")
32 break
33 case "deepseek":
34 window.open("https://chat.deepseek.com/", "_blank")
35 break
36 }
37 }
38
39 return [aiContent, handleSetContent]
40}

Callers 15

CustomDomSelectorFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90
PlasmoOverlayFunction · 0.90

Calls 1

TurndownFunction · 0.85

Tested by

no test coverage detected