cherry-markdown icon indicating copy to clipboard operation
cherry-markdown copied to clipboard

[Feature Request] 新增目录开关的API实现

Open Wscats opened this issue 1 year ago • 4 comments

Prerequisites

  • [ ] There isn't an existing issue that requests the same feature, to avoid duplicates.

Clear and concise description of the problem

企业微信截图_9fae56e3-3c93-4b22-8fb7-d2835084e28d 这个目录的开关可否新增个API呢😊 类似这样的调用方式

Suggested solution

cherry.toolbar.toolbarHandlers.toggleToc();

感谢🙏

Wscats avatar Sep 06 '24 08:09 Wscats

你指的是在开启toc模式下,控制toc的展开和折叠?

RSS1102 avatar Sep 06 '24 08:09 RSS1102

你指的是在开启toc模式下,控制toc的展开和折叠?

是的,开启了toc,想用接口方式调用展开和折叠

Wscats avatar Sep 06 '24 08:09 Wscats

目前没有开放出来api,不过可以通过下面的方式控制,欢迎尝试哈:

// 展开
cherry.toc.$switchModel('full')
cherry.toc.setModelToLocalStorage('full')

// 收起
cherry.toc.$switchModel('pure')
cherry.toc.setModelToLocalStorage('pure')

sunsonliu avatar Sep 06 '24 09:09 sunsonliu

目前没有开放出来api,不过可以通过下面的方式控制,欢迎尝试哈:

// 展开
cherry.toc.$switchModel('full')
cherry.toc.setModelToLocalStorage('full')

// 收起
cherry.toc.$switchModel('pure')
cherry.toc.setModelToLocalStorage('pure')

好的呢~我试试

Wscats avatar Sep 06 '24 09:09 Wscats

cherryObj.toggleToc(); // 切换状态
cherryObj.toggleToc('full'); // 强制切换到全屏状态
cherryObj.toggleToc('pure'); // 强制切换到极简状态

已新增api,可以参考api文档:https://tencent.github.io/cherry-markdown/examples/api.html

sunsonliu avatar Jan 03 '25 01:01 sunsonliu