@xiee/utils 1.3.17 → 1.3.18
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/README.md +3 -3
- package/js/fullwidth.js +6 -1
- package/js/fullwidth.min.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -58,9 +58,9 @@ Fix the table of contents generated by lower versions of Hugo.
|
|
|
58
58
|
|
|
59
59
|
## fullwidth.js
|
|
60
60
|
|
|
61
|
-
Find `<pre
|
|
62
|
-
they are too wide, so they can be styled
|
|
63
|
-
bleed](https://css-tricks.com/full-bleed/)).
|
|
61
|
+
Find `<pre>`, `<table>`, and TOC (with ID `TableOfContents`) elements and add
|
|
62
|
+
the `fullwidth` class to them if they are too wide, so they can be styled
|
|
63
|
+
differently (e.g., [full bleed](https://css-tricks.com/full-bleed/)).
|
|
64
64
|
|
|
65
65
|
## hash-notes.js
|
|
66
66
|
|
package/js/fullwidth.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// look for overflowed <pre> and <table>, and assign .fullwidth class to them
|
|
2
|
-
document.querySelectorAll('pre,table').forEach(node => {
|
|
2
|
+
document.querySelectorAll('pre,table,#TableOfContents').forEach(node => {
|
|
3
3
|
function fullwidth(el) {
|
|
4
4
|
el.classList.add('fullwidth');
|
|
5
5
|
}
|
|
@@ -13,5 +13,10 @@ document.querySelectorAll('pre,table').forEach(node => {
|
|
|
13
13
|
p && p.offsetWidth < node.offsetWidth && fullwidth(node);
|
|
14
14
|
break;
|
|
15
15
|
default:
|
|
16
|
+
// assume it's #TableOfContents for now
|
|
17
|
+
node.querySelectorAll('a').forEach(a => {
|
|
18
|
+
// if a TOC line is wrapped, make TOC full-width
|
|
19
|
+
!node.classList.contains('fullwidth') && a.getClientRects().length > 1 && fullwidth(node);
|
|
20
|
+
});
|
|
16
21
|
}
|
|
17
22
|
});
|
package/js/fullwidth.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
document.querySelectorAll("pre,table").forEach((t=>{function e(t){t.classList.add("fullwidth")}switch(t.tagName){case"PRE":const
|
|
1
|
+
document.querySelectorAll("pre,table,#TableOfContents").forEach((t=>{function e(t){t.classList.add("fullwidth")}switch(t.tagName){case"PRE":const l=t.firstElementChild;"CODE"===l?.tagName&&l.scrollWidth>l.offsetWidth&&e(l);break;case"TABLE":const a=t.parentElement;a&&a.offsetWidth<t.offsetWidth&&e(t);break;default:t.querySelectorAll("a").forEach((l=>{!t.classList.contains("fullwidth")&&l.getClientRects().length>1&&e(t)}))}}));
|