DiscoTOC - automatic table of contents

interesting. the link from within your forum seems to have the anchor stripped from it.

I checked on my site and have repro.

1 Like

Interesting - just updated today and getting this scary warning across the top. But the site seems to be fine so far.

:warning: Your site may not work because theme / component DiscoTOC has errors. Disable it at /admin/customize/themes.


DiscoTOC theme/component is throwing errors
Error: Could not find module ember-addons/ember-computed-decorators
    at https://DISCOURSE/assets/ember_jquery-7d202b640076468b0bd81a4231650174c1a75aec26f132bb7dc3dfad7985b6ff.js:1:554211
    at require (https://DISCOURSE/assets/ember_jquery-7d202b640076468b0bd81a4231650174c1a75aec26f132bb7dc3dfad7985b6ff.js:1:554249)
    at https://DISCOURSE/theme-javascripts/d829ea593b9ddad05ea983e6419ea86ee453ee60.js?__ws=DISCOURSE:21:24
    at e.withPluginApi (https://DISCOURSE/assets/application-5b495fcb7ef238c0b1efb890288628c6c2a88722f76a13aa45a533b7c0dda246.js:1:418956)
    at Object.initialize (https://DISCOURSE/assets/application-5b495fcb7ef238c0b1efb890288628c6c2a88722f76a13aa45a533b7c0dda246.js:1:205795)
    at https://DISCOURSE/assets/ember_jquery-7d202b640076468b0bd81a4231650174c1a75aec26f132bb7dc3dfad7985b6ff.js:1:334072
    at i.each (https://DISCOURSE/assets/ember_jquery-7d202b640076468b0bd81a4231650174c1a75aec26f132bb7dc3dfad7985b6ff.js:1:494808)
    at i.walk (https://DISCOURSE/assets/ember_jquery-7d202b640076468b0bd81a4231650174c1a75aec26f132bb7dc3dfad7985b6ff.js:1:493827)
    at t.each (https://DISCOURSE/assets/ember_jquery-7d202b640076468b0bd81a4231650174c1a75aec26f132bb7dc3dfad7985b6ff.js:1:493274)
    at t.topsort (https://DISCOURSE/assets/ember_jquery-7d202b640076468b0bd81a4231650174c1a75aec26f132bb7dc3dfad7985b6ff.js:1:493320)
hostname	discourse-app
process_id	17610
application_version	6275c05c0de4da501bf9e5ba40a82280c79ec6a8
REQUEST_URI	/logs/report_js_error
HTTP_USER_AGENT	Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.87 Safari/537.36
message	DiscoTOC theme/component is throwing errors
stacktrace	Error: Could not find module ember-addons/ember-computed-decorators at https://DISCOURSE/

I think this is fixed in the latest commit 2hrs ago?


yep - that’s the likely culprit. I updated again and error went away.

Yes that fixed it. We changed some Ember stuff in core which threw this warning up if this component was in use. Updating the component fixes it.


I love the look and feel of this component and it works beautifully in Chrome, but in Safari it seems it still has the issues that were claimed to have been fixed (no jumping to the topics when a TOC items is clicked, no bolding of current topic etc)? I just installed the latest from the git repo or should I have a different fork/branch etc?


Yes, the component is great, but it doesn’t work in some clients. For example, it also does not work on iphones (no jumping to items as you describe when the item is clicked). But, works great on androids. We’ve tried to debug this, but cannot figure it either why it works on some clients, but not others.

1 Like

:frowning: indeed, and given we’re using it 90% on Safari/WebKit I’m afraid that if it can’t be made to work I have to take it off again, which would be a shame because the concept is fantastic

1 Like

What I didn’t get was that an earlier post suggests that @Johani fixed things in version 0.2 for Safari, which makes we wonder whether things regressed again or whether Safari continues to change in a way that it broke again?

1 Like

I just pushed a fix for the Safari issue.

I’m pretty sure I tested it and saw no issue when v0.2 came out, but Safari required some hacks back then - even though the component follows web standards.

That said, I justed tested again on the latest Safari and there’s no need for the hacks anymore. So, I removed them. My guess is that the old hacks were preventing the component from functioning properly on Safari.

As for the rest of the issues reported here, thanks for those. I haven’t had the time to look at them, but will do so soon :+1:


Woot, thank you so much, saw Discourse reporting the update being available (just can’t get over how good discourse is, that alone is amazing). Works brilliantly! :clap:

Keep up the good work!


Is there any way to display a TOC only for posts within a topic created by the topic author?

No, this only works for the contents of the first post in a topic.

as you can see

the problem is when I post a new topic and then use edit opiton ,I can find table insert in the composer,but when I hit both of the reply option,it is gone what happened

Hello and thanks for your interest in DiscoTOC. I’m not entirely sure what you are doing, but it looks like you are clicking in the wrong place to save your post. See my screenshot below - after inserting the TOC markdown, I can then write the rest of my post and then select the CREATE TOPIC button in the bottom left corner to post it.


that is entirely right .what I got is exactly what you show .when I create a topic ,toc shows in composer tools menu.
after this topic is created, and anyone including the creator who wants to post comments,then you could not find this toc tool menu though.

Only the first post in a topic can get a TOC.

1 Like

thx finally .and "<div data-theme-toc="true">xxx</div>" should be in the first line

Images are displayed onto the blue banner. It ain’t much of an issue but anyways

I ain’t good at all with CSS so I can’t really correct it myself '^^ sorry

Not sure exactly what is going on in your screenshot. My suggestion would be to place the embed code only at the top or bottom of the post, on its own line with an empty line between it and any other content. You also only need to include it once.