decker-edu / decker

A markdown based tool for slide deck creation.
GNU General Public License v3.0
55 stars 14 forks source link

Autogenerated Index page and search feature #56

Closed MatthiasPopp closed 8 months ago

MatthiasPopp commented 10 months ago

Hi everyone, I am experiencing issues with the fuzzysearch feature on the autogenerated index page.

When compiling the example presentation with the 0.13.2 release and switching between the resource packs, e.g. between exe:[mono|mario|decker|wburg|nwburg], the respective media div (the one which gets the search field injected) has the wrong id. Sometimes there is a "id_" prepended to the hash value, and thus the anchor cannot be found.

Have a look at the line with the hightlighted word "anchor".

image

The javascript of the index.html is crashing here:

<script type="module" defer="">
let anchor = document.getElementById("11d551db0"); <!-- here -->
import("./" + Decker.meta.supportPath + "/fuzzySearch/search.js")
    .then((module) => {
      anchor.classList.add("search");
      anchor.innerHTML = `
        <p>
          <i class="fa-solid fa-magnifying-glass"></i>
          <input class="search" placeholder="In Folien suchen" type="text">
        </p>
        <table class="search">
        <thead><tr><th>Wort</th><th>Foliensatz</th><th>Folie</th><th>Treffer</th></tr></thead>
        <tbody></tbody>
        </table>
      `;
      module.default(anchor, 0.6);
    });
</script>

Interestingly this is random behaviour. I tried the following:

I found that in the Media.hs there is a comment about prepending a id_ because es6 does not support ids with numerals but then the getElementByIdshould be outdated right?

Best regards, Matthias

monofon commented 10 months ago

Thanks, that seems to have been fixed quite some time ago, but did escape the merge from develop. I am releasing a fix right now.