-
Notifications
You must be signed in to change notification settings - Fork 832
feat: anchor link #1221
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
base: main
Are you sure you want to change the base?
feat: anchor link #1221
Conversation
fuscodev
commented
Jun 4, 2025
- close [Feature Request] Anchor Links #610
While working on a feature based on your awesome work, I thought about saving the slug as part of the block. When linking it, this would mean that even if you change the heading a little (for example, fixing spelling mistakes, adding parentheses, or something else), the link would not break. The downside is that this could still leave unwanted or old headings in the anchor, but this could be fixed by just removing the block and creating a new heading. What do you think of this idea? |
It's a great idea. We can create a random uuid. What do you think? |
Oh, a UUID might be an option. But I think we should use the same slug generation that is used for pages. TLDR; I had the idea for mention links (so that you can select a anchor with a mention). It's working quite good: Vito0912@f551cf4. So maybe also something to pick up. Not sure if I ever will make a PR with it, as it will definitly be slower when having many many pages (due to content) and I have it as a part of customized version of your PR with faster scrolling (on loading) and moved the anchor item to not change the layout on hover: Vito0912@4d85f83 (but it has it's own flaws - like weird behaviour in edit mode) Edit: Corrected "mention links" |
The tiptap UniqueID extension is now open source. |
I would also choose nanoId. I think it is already used for the page ID? The main benefit is that it makes copying easier, because some browsers do not copy the dash when you double tap. So would you be ok with storing a uid (nanoid) with the headers (to make anchors more stable) potentially with your named extension? |
The Unique ID extension does that already, so we can go with it. |
I created a PoC for this. https://github.com/Vito0912/forkmost/tree/feat/anchorStatic Sadly it only seems to work in the editor and not for shared pages. There the ID is not stable. So it looks like that we still need to extend the header by an id and save it to the db - which I thought this would do? The format now uses the old slug system with Maybe we can also make the scrolling better? I used an observer in on of my other branches, but it did not work that well in edit mode. When the editor switches from read to edit mode (connects), the scroll action gets reset mid scrolling. |
@Vito0912 I merged your changes. I rewrite the url with the current "id" In shared pages the anchors are not working correctly because of this line |
Thank you very much! Your idea with
Thank you for the information. Would have never guessed that tbh. If you have time and are ok with it, could you explain why this happens? Is it just because of the conversion in between? Also, to avoid spamming here, if you use Discord, you can contact me at One more thing: In the future, could you please merge these changes by creating a PR to your repo [Or I can do - Just thought that my commit was to unfinished because of the shared pages not working]? This way, the commit history stays clean and there are no potential merge conflicts. |
I fix the issue in shared pages. I updated the extensions schema server side in |
Shouldn't |
Shared pages only fetch content, they are read-only and don't have any realtime updates. Therefore |