mirror of
https://github.com/027xiguapi/code-box.git
synced 2026-05-21 17:39:02 +00:00
24 lines
584 B
TypeScript
24 lines
584 B
TypeScript
import { Storage } from "@plasmohq/storage"
|
|
import { useStorage } from "@plasmohq/storage/dist/hook"
|
|
|
|
import Turndown from "~utils/turndown"
|
|
|
|
export function useEditMarkdown(option?) {
|
|
const turndownService = Turndown(option)
|
|
|
|
const [content, setContent] = useStorage({
|
|
key: "md-content",
|
|
instance: new Storage({
|
|
area: "local"
|
|
})
|
|
})
|
|
|
|
const handleSetContent = (selectorDom) => {
|
|
const markdown = turndownService.turndown(selectorDom)
|
|
setContent(markdown)
|
|
window.open("https://md.randbox.top", "_blank")
|
|
}
|
|
|
|
return [content, handleSetContent]
|
|
}
|