spec-up-t 1.0.37 → 1.0.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/compiled/body.js +1 -1
- package/assets/js/search.js +26 -1
- package/package.json +1 -1
package/assets/compiled/body.js
CHANGED
|
@@ -88,7 +88,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
88
88
|
* @since 2024-06-09
|
|
89
89
|
*/
|
|
90
90
|
function editTermButtons(){const t=((e=specConfig.spec_directory).startsWith("./")?e=e.substring(2):e.startsWith("/")&&(e=e.substring(1)),e.endsWith("/")&&(e=e.slice(0,-1)),e);var e;document.querySelectorAll('dt:has(> span[id^="term:"])').forEach(e=>{const n=function(t){let e=t;for(;e.querySelector('span[id^="term:"]');)e=e.querySelector('span[id^="term:"]');return e}(e),s=n.getAttribute("id").split(":")[1];n.innerHTML+=`<span class="edit-term-buttons"><a title="Link to the term file in the Github repo in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/blob/main/${t}/${specConfig.spec_terms_directory}/${s}.md" class="edit-term-button btn">🖊️</a><a title="Link to a GitHub page that shows a history of the edits in a new tab" target="_blank" rel="noopener" href="https://github.com/${specConfig.source.account}/${specConfig.source.repo}/commits/main/${t}/${specConfig.spec_terms_directory}/${s}.md" class="history-term-button btn">📅</a></span>`})}document.addEventListener("DOMContentLoaded",(function(){editTermButtons()}));
|
|
91
|
-
function inPageSearch(){const e=document.querySelector("span[issue-count]"),t=specConfig.searchHighlightStyle||"ssi",n="search-h7vc6omi2hr2880",i=document.querySelector("main article");let c=document.createElement("div");c.setAttribute("id","container-"+n),c.setAttribute("class","container-"+n),e.after(c);let o=document.createElement("input");o.setAttribute("type","text"),o.setAttribute("id",n),o.setAttribute("placeholder","🔍"),c.appendChild(o),setTimeout(()=>{o.focus()},1e3);const
|
|
91
|
+
function inPageSearch(){const e=document.querySelector("span[issue-count]"),t=specConfig.searchHighlightStyle||"ssi",n="search-h7vc6omi2hr2880",i=document.querySelector("main article");let c=document.createElement("div");c.setAttribute("id","container-"+n),c.setAttribute("class","container-"+n),e.after(c);let o=document.createElement("input");o.setAttribute("type","text"),o.setAttribute("id",n),o.setAttribute("placeholder","🔍"),c.appendChild(o),setTimeout(()=>{o.focus()},1e3);const s=document.createElement("div");s.setAttribute("id","back-and-forth-buttons-container-"+n);const r=document.createElement("button");r.setAttribute("id","one-match-backward-"+n),r.setAttribute("disabled","disabled"),r.setAttribute("title","Go to previous match. Shortcut key: Left Arrow"),r.textContent="▲",s.appendChild(r);const a=document.createElement("button");a.setAttribute("id","one-match-forward-"+n),a.setAttribute("disabled","disabled"),a.setAttribute("title","Go to next match. Shortcut key: Right Arrow"),a.textContent="▼",s.appendChild(a),c.appendChild(s);const d=document.createElement("span");d.setAttribute("id","total-matches-"+n),d.innerHTML="0 matches",c.appendChild(d),o.addEventListener("input",(function(){g(o.value)})),document.addEventListener("click",e=>{e.target.classList.contains("collapse-all-defs-button")&&g(o.value)});const l="highlight-matches-"+n,h={dif:"highlight-matches-DIF-search-h7vc6omi2hr2880",toip:"highlight-matches-ToIP-search-h7vc6omi2hr2880",btc:"highlight-matches-BTC-search-h7vc6omi2hr2880",keri:"highlight-matches-KERI-search-h7vc6omi2hr2880",ssi:"highlight-matches-SSI-search-h7vc6omi2hr2880",gleif:"highlight-matches-GLEIF-search-h7vc6omi2hr2880"}[t.toLowerCase()];let u=0,m=-1;function b(e){e.scrollIntoView({behavior:"smooth",block:"start"});const t=e.getBoundingClientRect(),n=t.top+window.pageYOffset-(window.innerHeight-t.height)/2;window.scrollTo({top:n,behavior:"smooth"})}function p(){m<=0?document.getElementById("one-match-backward-"+n).setAttribute("disabled","disabled"):document.getElementById("one-match-backward-"+n).removeAttribute("disabled"),m>=u-1?document.getElementById("one-match-forward-"+n).setAttribute("disabled","disabled"):document.getElementById("one-match-forward-"+n).removeAttribute("disabled")}function f(){d.innerHTML=u+" matches"}const g=function(e,t){let n;return function(){const i=this,c=arguments;clearTimeout(n),n=setTimeout(()=>e.apply(i,c),t)}}((function(e){if(function(){document.querySelectorAll("span."+l).forEach(e=>{Array.from(e.childNodes).forEach(t=>{t.nodeType===Node.ELEMENT_NODE&&e.removeChild(t)}),e.classList.contains(l)&&(e.outerHTML=e.innerHTML)})}(),u=0,m=-1,""===e)return void f();let t=0;!function i(c){if(3!==c.nodeType||function(e){for(;e;){if(e.classList&&e.classList.contains("hidden"))return!0;e=e.parentNode}return!1}(c))1===c.nodeType&&Array.from(c.childNodes).forEach(i);else{const i=function(i){const c=i.nodeValue,o=new RegExp(e,"gi");let s,r=0,a=document.createDocumentFragment();for(;null!==(s=o.exec(c));){a.appendChild(document.createTextNode(c.substring(r,s.index)));const e=document.createElement("span");e.textContent=s[0],e.classList.add(l),e.classList.add(h),e.setAttribute("id",n+"-"+t),a.appendChild(e),u=t+1,t++,r=s.index+s[0].length}return a.appendChild(document.createTextNode(c.substring(r))),a}(c);i.childNodes.length>1&&c.parentNode.replaceChild(i,c)}}(i);let c=document.querySelector("."+h);null!==c&&b(c);f(),p(),m=-1}),600);r.addEventListener("click",(function(){m--;const e=document.querySelector("#"+n+"-"+m);e&&b(e),e.classList.add("active"),setTimeout(()=>{e.classList.remove("active")},3e3),p()})),a.addEventListener("click",(function(){m++;const e=document.querySelector("#"+n+"-"+m);e&&b(e),e.classList.add("active"),setTimeout(()=>{e.classList.remove("active")},3e3),p()})),document.addEventListener("keyup",e=>{switch(e.key){case"ArrowRight":a.click();break;case"ArrowLeft":r.click()}})}document.addEventListener("DOMContentLoaded",(function(){inPageSearch()}));
|
|
92
92
|
function highlightMenuItems(){let t=null;function e(t){document.querySelectorAll("#toc_list a").forEach(t=>{t.classList.remove("highlight-cfib41dyhcd99sm")});const e=document.querySelector(`#toc_list a[href="#${t.id}"]`);e&&(e.classList.add("highlight-cfib41dyhcd99sm"),e.scrollIntoView({behavior:"smooth",block:"center"}))}const o=new IntersectionObserver((o,n)=>{const c=o.filter(t=>t.isIntersecting).map(t=>t.target);c.length>0?(t=c[0],e(t)):t&&e(t)},{root:null,rootMargin:"0px",threshold:.1});document.querySelectorAll("h2, h3, h4, h5, h6").forEach(t=>o.observe(t))}document.addEventListener("DOMContentLoaded",(function(){highlightMenuItems()}));
|
|
93
93
|
function backToTop(){const n=document.createElement("a");n.id="back-to-top-a1zncgtqfpzsig8",n.href="#content",n.innerHTML="↑",document.body.appendChild(n);const t=function(n,t){let e;return function(){const o=this,c=arguments;clearTimeout(e),e=setTimeout(()=>n.apply(o,c),t)}}((function(){window.scrollY>300?n.style.display="flex":n.style.display="none"}),600);window.addEventListener("scroll",(function(){t()}))}document.addEventListener("DOMContentLoaded",(function(){backToTop()}));
|
|
94
94
|
/**
|
package/assets/js/search.js
CHANGED
|
@@ -87,13 +87,20 @@ function inPageSearch() {
|
|
|
87
87
|
totalMatchesSpan.innerHTML = `0 ${matches}`;
|
|
88
88
|
// backAndForthButtonsContainer.after(totalMatchesSpan);
|
|
89
89
|
searchContainer.appendChild(totalMatchesSpan);
|
|
90
|
+
|
|
91
|
+
/* END Add DOM elements */
|
|
90
92
|
|
|
91
93
|
// Add an event listener to the input element
|
|
92
94
|
searchInput.addEventListener("input", function () {
|
|
93
95
|
debouncedSearchAndHighlight(searchInput.value);
|
|
94
96
|
});
|
|
95
|
-
/* END Add DOM elements */
|
|
96
97
|
|
|
98
|
+
// The search will run when the user clicks the collapse button, so the search results are updated when the terms are collapsed or expanded. If the definitions are collapsed, the search results in the definitions will be removed.
|
|
99
|
+
document.addEventListener('click', event => {
|
|
100
|
+
if (event.target.classList.contains('collapse-all-defs-button')) {
|
|
101
|
+
debouncedSearchAndHighlight(searchInput.value);
|
|
102
|
+
}
|
|
103
|
+
});
|
|
97
104
|
|
|
98
105
|
const matchesClassName = "highlight-matches-" + antiNameCollisions;
|
|
99
106
|
const matchesStyleSelectorClassName = matchesStyleSelector[matchesStyle.toLowerCase()];
|
|
@@ -264,7 +271,25 @@ function inPageSearch() {
|
|
|
264
271
|
|
|
265
272
|
// Recursive function that searches all nodes in the DOM tree and highlights the text that matches the search string (case-insensitive) with a span element
|
|
266
273
|
function searchNodes(node) {
|
|
274
|
+
/*
|
|
275
|
+
Helper function to check if any ancestor has the 'hidden' class. Why the 'hidden' class? Because we don't want to highlight text that is hidden, and 'hidden' is the class that is used in the JS that collapses and expands the terms and definitions in the specs. The class is applied to the <dd>'s
|
|
276
|
+
*/
|
|
277
|
+
function hasHiddenAncestor(node) {
|
|
278
|
+
while (node) {
|
|
279
|
+
if (node.classList && node.classList.contains('hidden')) {
|
|
280
|
+
return true;
|
|
281
|
+
}
|
|
282
|
+
node = node.parentNode;
|
|
283
|
+
}
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// A:
|
|
267
288
|
if (node.nodeType === 3) { // Node.TEXT_NODE
|
|
289
|
+
|
|
290
|
+
// B: ”&& !hasHiddenAncestor(node)” makes search only in terms when definitions are collapsed
|
|
291
|
+
// if (node.nodeType === 3 && !hasHiddenAncestor(node)) { // Node.TEXT_NODE
|
|
292
|
+
|
|
268
293
|
const fragments = markAndCountMatches(node);
|
|
269
294
|
if (fragments.childNodes.length > 1) {
|
|
270
295
|
// Replace the text node with the fragments if there were matches
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spec-up-t",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.38",
|
|
4
4
|
"description": "Technical specification drafting tool that generates rich specification documents from markdown. Forked from https://github.com/decentralized-identity/spec-up by Daniel Buchner (https://github.com/csuwildcat)",
|
|
5
5
|
"main": "./index",
|
|
6
6
|
"repository": {
|