wobsoriano / lexical-vue

An extensible Vue 3 web text-editor based on Lexical.
https://lexical-vue.vercel.app/
MIT License
251 stars 30 forks source link

Add table of contents use function without plugin or UI #51

Closed zswaff closed 3 months ago

zswaff commented 3 months ago

Adapted directly from the react version with minimal changes.

In theory we could add more so that there is a builtin UI (like this) but this is all pretty implementation-specific. In our project we will want some of this functionality (scroll on click) but obviously different UI. How do you usually like to handle this sort of thing?


Tested in our project. One easy way to test here is just to add it to the playground and do something like

const toc = useTableOfContents(editor)
watch(toc, () => {
  console.log(toc.value)
})

You will see the any update to any heading print the expected changes.

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lexical-vue ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 7:31am
lexical-vue-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 29, 2024 7:31am