加载此插件可以使得编辑器支持目录功能。
- 用法
const Editor = shimo.sdk.document.Editor
const TableOfContent = shimo.sdk.document.plugins.TableOfContent
const editor = new Editor()
const tableOfContent = new TableOfContent({
editor,
...options
})
- 参数
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
editor |
Editor |
必选 | 编辑器实例 |
渲染初始化。
- 返回
undefined
- 用法
tableOfContent.render(container)
- 参数
名称 | 类型 | 默认值 | 描述 |
---|---|---|---|
container |
HTMLElement |
可选 | 渲染容器 |
显示目录
- 返回
undefined
- 用法
tableOfContent.show()
隐藏目录
- 返回
undefined
- 用法
tableOfContent.hide()
销毁实例。
- 返回
undefined
- 用法
tableOfContent.destroy()
// 目录显示
tableOfContent.on(TableOfContent.events.SHOW, () => {})
// 目录隐藏
tableOfContent.on(TableOfContent.events.HIDE, () => {})
// 目录更新
tableOfContent.on(TableOfContent.events.UPDATE, () => {})