Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] getToc延迟问题 #708

Closed
1 task done
joker585 opened this issue Jan 29, 2024 · 2 comments
Closed
1 task done

[Feature Request] getToc延迟问题 #708

joker585 opened this issue Jan 29, 2024 · 2 comments
Labels

Comments

@joker585
Copy link

Prerequisites

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

Clear and concise description of the problem

cherryObj.setMarkdown('')
console.log(cherryObj.getToc());
当我这样去获取目录时,获取到的不是''计算出的目录,而是上一个value所计算出来的,我只能在getToc加上setTimeout来hack这个问题,希望可以修正这个问题或者抛给我一个额外的api可以让我自己从一段字符串中计算出正确的目录

Suggested solution

No response

Further Information

No response

Contributing

None

@joker585 joker585 added the enhancement New feature or request label Jan 29, 2024
@sunsonliu
Copy link
Collaborator

image

setMarkdown确实是异步的,这是codemirror的机制导致的。可以考虑用afterChange这个回调函数配置哈。

另外如果单纯的想实现悬浮目录的话,可以考虑用cherry自带的toc悬浮目录哈,配置如下:
image

效果可以在 https://tencent.github.io/cherry-markdown/examples/index.html 这里体验

@RSS1102 RSS1102 added question and removed enhancement New feature or request labels Jan 29, 2024
@joker585
Copy link
Author

好的感谢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants