yuque-editor-core
v0.0.5
Published
Yuque/Lake editor core with offline assets
Downloads
500
Maintainers
Readme
yuque-editor-core
语雀(Lake)编辑器的核心封装,默认使用离线资源,不依赖运行时联网。
安装
pnpm add yuque-editor-core资源(离线)
本项目已内置离线资源文件,构建后会把 assets/yuque-assets 拷贝到 dist/yuque-assets。
浏览器运行时需要把这些静态文件以 /yuque-assets/* 的路径提供出来(例如放到站点的 public 目录)。
使用
原生(DOM)
import { createYuqueEditor } from "yuque-editor-core/editor"
const ref = await createYuqueEditor({
container: document.getElementById("app")!,
value: "<p>Hello</p>"
})React
import React from "react"
import YuqueEditor from "yuque-editor-core/react"
export default function App() {
const [value, setValue] = React.useState("<p>Hello</p>")
return <YuqueEditor value={value} scheme="text/html" onChange={setValue} />
}Vue 3
import YuqueEditor from "yuque-editor-core/vue"
export default {
components: { YuqueEditor }
}插件配置
在开发/构建时自动把离线资源拷贝到项目 public/yuque-assets,可以使用:
import { yuqueAssets } from "yuque-editor-core/vite-assets"
export default {
plugins: [yuqueAssets()]
}