Links in Table of Contents not working #3502
Replies: 8 comments 4 replies
-
TOC links work just fine here: https://docs.requarks.io/releases Are you using the markdown or visual editor? |
Beta Was this translation helpful? Give feedback.
-
I'm using the markdown editor, and none of the headings in the page's content haven an id attribute, so I'm assuming that is the reason the scroll doesn't work. |
Beta Was this translation helpful? Give feedback.
-
Hi All, Have the same issue. Uncaught Error: Target element "#links" not found.
M https://some.page.net/_assets/js/app.js?1603683027:350
T https://some.page.net/_assets/js/app.js?1603683027:350
onclick https://some.page.net/_assets/js/theme0.js?1603683027:2
mounted https://some.page.net/_assets/js/theme0.js?1603683027:2
mounted https://some.page.net/_assets/js/theme0.js?1603683027:2
ie https://some.page.net/_assets/js/app.js?1603683027:350
Xt https://some.page.net/_assets/js/app.js?1603683027:350 OS: Linux Regards, |
Beta Was this translation helpful? Give feedback.
-
I can reproduce this issue. Using WikiJs 2.5.197 and markdown:
Click in Table Of Contents returns OS: Linux |
Beta Was this translation helpful? Give feedback.
-
I have the same issue, running Stable 2.5.201. I am using the Markdown editor with one simple document:
The Table of Contents shows but the link to SubHeader is not working. I am seeing the same vue.js error in the console and see in the HTML there are no anchors being created. I also tried copying the source (markdown) exactly copy and paste form: The links still don't work. |
Beta Was this translation helpful? Give feedback.
-
TL;DRGo to Admin > Rendering > html to html > Security, then disable Sanitize HTML. Technical explanationIn the security renderer, Wiki.js uses DOMPurify to sanitise the HTML. Using the default options, DOMPurify would prevent DOM Clobbering by removing Property names in document/formElement?It's a long list so I won't be writing it out here. Open your developer console F12, type TestYou can test the DOMPurify using their demo. For example: <h1 id="links">Links</h1>
<h1 id="link">Link</h1>
<h1 id="images">Images</h1>
<h1 id="image">Image</h1>
<h1 id="action">Action</h1> turns into <h1>Links</h1>
<h1 id="link">Link</h1>
<h1>Images</h1>
<h1 id="image">Image</h1>
<h1>Action</h1> SolutionsI think the DOMPurify is a good feature to prevent some nasty XSS attacks or messy DOM. A few solutions I can think of now for @NGPixel : Disable SANITIZE_DOMWiki.js can outright disable SANITIZE_DOM: DOMPurify.sanitize(dirty, {SANITIZE_DOM: true}); However, SANITIZE_DOM is for Provide DOMPurify options to customizeWiki.js can extend the options to let us customize the configuration for the dependency it has. However, this will lead to more costly maintenance. Header id prefixThis is widely discussed in markdown-it. There are a few plugins to implement the idea, but still an open issue. References |
Beta Was this translation helpful? Give feedback.
-
Another possibility I've known for a broken table of content is HTML Core disabled in Admin > Rendering > html to html > Security. Wiki.js converts the Markdown into HTML, then process the HTML to further enhance it. More info on Wiki.js Rendering Pipeline. |
Beta Was this translation helpful? Give feedback.
-
Submitted PR #4527 to attempt to fix the variant of this issue caused by custom header IDs as experienced by myself, @vkatsuba, and @Lurkars . I'd love your testing/feedback. I don't believe this will resolve the other issues discussed here, which seem to related to sanitization happening before rendering reaches header-parsing, but maybe I'm misunderstanding the rendering order. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Clicking on a the links in the Table of Contents doesn't scroll down to the clicked heading, and produces the following error in the console:
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The page to be scrolled down to the clicked link heading
Host Info (please complete the following information):
Additional context
It seems there are no anchors generated, when inspecting the pages' html source
Beta Was this translation helpful? Give feedback.
All reactions