@xiee/utils 1.9.4 → 1.9.5
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 +6 -0
- package/js/fold-output.js +24 -0
- package/js/fold-output.min.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,6 +83,12 @@ blocks (`<pre>`) are folded. Other elements can also be folded via custom
|
|
|
83
83
|
options. See [this post](https://yihui.org/en/2023/09/code-folding/) for more
|
|
84
84
|
information.
|
|
85
85
|
|
|
86
|
+
## fold-output.js
|
|
87
|
+
|
|
88
|
+
Click on a code block of the class `language-*` to toggle the visibility of its
|
|
89
|
+
siblings on the page before the next `language-*` block. Click while holding the
|
|
90
|
+
`Alt` key to toggle siblings of all `language-*` blocks on the page.
|
|
91
|
+
|
|
86
92
|
## fullwidth.js
|
|
87
93
|
|
|
88
94
|
Find `<pre>`, `<table>`, and TOC (with ID `TableOfContents`) elements and add
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// toggle output of source code by clicking on source code
|
|
2
|
+
(() => {
|
|
3
|
+
const blocks = [];
|
|
4
|
+
document.querySelectorAll('pre>code[class^=language-],pre[class^=language-]').forEach(el => {
|
|
5
|
+
// if <code> is selected, use its parent
|
|
6
|
+
if (el.tagName === 'CODE' && el.parentNode.tagName === 'PRE') el = el.parentNode;
|
|
7
|
+
blocks.indexOf(el) < 0 && blocks.push(el);
|
|
8
|
+
});
|
|
9
|
+
let s1, s2; // local and global show/hide status
|
|
10
|
+
blocks.forEach(el => {
|
|
11
|
+
el.onclick = e => {
|
|
12
|
+
let sb = el.nextElementSibling;
|
|
13
|
+
while (sb && blocks.indexOf(sb) < 0) {
|
|
14
|
+
s1 = s2; // use global status if exists
|
|
15
|
+
if (s1 === undefined) s1 = sb.style.display === '';
|
|
16
|
+
sb.style.display = s1 ? 'none' : '';
|
|
17
|
+
sb = sb.nextElementSibling;
|
|
18
|
+
}
|
|
19
|
+
// Alt + Click to toggle all output
|
|
20
|
+
e.altKey && (s2 = s1, blocks.forEach(b => b !== el && b.click()), s2 = undefined);
|
|
21
|
+
s1 = undefined;
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{const e=[];let l,a;document.querySelectorAll("pre>code[class^=language-],pre[class^=language-]").forEach((l=>{"CODE"===l.tagName&&"PRE"===l.parentNode.tagName&&(l=l.parentNode),e.indexOf(l)<0&&e.push(l)})),e.forEach((n=>{n.onclick=t=>{let o=n.nextElementSibling;for(;o&&e.indexOf(o)<0;)l=a,void 0===l&&(l=""===o.style.display),o.style.display=l?"none":"",o=o.nextElementSibling;t.altKey&&(a=l,e.forEach((e=>e!==n&&e.click())),a=void 0),l=void 0}}))})();
|