@xiee/utils 1.8.0 → 1.9.0
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 +5 -0
- package/css/docco-classic.css +86 -0
- package/css/docco-classic.min.css +1 -0
- package/js/docco-classic.js +50 -0
- package/js/docco-classic.min.js +1 -0
- package/js/docco-resize.js +1 -0
- package/js/docco-resize.min.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -42,6 +42,11 @@ See [this post](https://yihui.org/en/2023/09/copy-button/) for details.
|
|
|
42
42
|
Convert definition lists `<dl>` to `<fieldset>`. See more information [in this
|
|
43
43
|
post](https://yihui.org/en/2023/11/dl-fieldset/).
|
|
44
44
|
|
|
45
|
+
## docco-classic.js
|
|
46
|
+
|
|
47
|
+
Find code blocks on a page and put them in the right column. Other elements will
|
|
48
|
+
be placed in the left column.
|
|
49
|
+
|
|
45
50
|
## external-link.js
|
|
46
51
|
|
|
47
52
|
If a link of `<a>` does not start with `http://` or `https://`, add the
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* Derived from the Docco package by Jeremy Ashkenas: https://github.com/jashkenas/docco/ */
|
|
2
|
+
body {
|
|
3
|
+
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
|
4
|
+
line-height: 1.5;
|
|
5
|
+
color: #30404f;
|
|
6
|
+
margin: 0;
|
|
7
|
+
padding: 0;
|
|
8
|
+
}
|
|
9
|
+
h1, h2, h3, h4, h5, h6 {
|
|
10
|
+
color: #112233;
|
|
11
|
+
font-weight: normal;
|
|
12
|
+
margin: 0 0 1rem 0;
|
|
13
|
+
}
|
|
14
|
+
.frontmatter {
|
|
15
|
+
text-align: center;
|
|
16
|
+
margin-top: 2em;
|
|
17
|
+
}
|
|
18
|
+
a {
|
|
19
|
+
color: #0088cc;
|
|
20
|
+
text-decoration: none;
|
|
21
|
+
}
|
|
22
|
+
a:hover, a:focus{
|
|
23
|
+
color: #005580;
|
|
24
|
+
text-decoration: underline;
|
|
25
|
+
}
|
|
26
|
+
table {
|
|
27
|
+
width: 100%;
|
|
28
|
+
border: 0;
|
|
29
|
+
}
|
|
30
|
+
td.docs, td.code {
|
|
31
|
+
width: 50%;
|
|
32
|
+
vertical-align: top;
|
|
33
|
+
padding: 1em 1em 1px 2em;
|
|
34
|
+
}
|
|
35
|
+
td.code{
|
|
36
|
+
background: #f5f5ff;
|
|
37
|
+
overflow-x: hidden;
|
|
38
|
+
}
|
|
39
|
+
code{
|
|
40
|
+
font-size: .8em;
|
|
41
|
+
}
|
|
42
|
+
td.docs code{
|
|
43
|
+
background: #f8f8ff;
|
|
44
|
+
border: 1px solid #dedede;
|
|
45
|
+
}
|
|
46
|
+
img {
|
|
47
|
+
max-width: 100%;
|
|
48
|
+
}
|
|
49
|
+
pre code{
|
|
50
|
+
display: block;
|
|
51
|
+
line-height: 1;
|
|
52
|
+
}
|
|
53
|
+
pre code:hover {
|
|
54
|
+
white-space: pre-wrap;
|
|
55
|
+
}
|
|
56
|
+
.pilwrap {
|
|
57
|
+
position: relative;
|
|
58
|
+
}
|
|
59
|
+
.pilcrow {
|
|
60
|
+
font: 12px Arial;
|
|
61
|
+
text-decoration: none;
|
|
62
|
+
color: rgb(69, 69, 69);
|
|
63
|
+
position: absolute;
|
|
64
|
+
top: 3px;
|
|
65
|
+
left: -1.5em;
|
|
66
|
+
padding: 1px 2px;
|
|
67
|
+
opacity: 0;
|
|
68
|
+
}
|
|
69
|
+
td.docs:hover .pilcrow {
|
|
70
|
+
opacity: 1;
|
|
71
|
+
}
|
|
72
|
+
blockquote {
|
|
73
|
+
border-left: 4px solid #DDD;
|
|
74
|
+
padding: 0 1em;
|
|
75
|
+
color: #777;
|
|
76
|
+
}
|
|
77
|
+
.container {
|
|
78
|
+
position: relative;
|
|
79
|
+
}
|
|
80
|
+
.handler{
|
|
81
|
+
width: 5px;
|
|
82
|
+
padding: 0;
|
|
83
|
+
cursor: col-resize;
|
|
84
|
+
position: absolute;
|
|
85
|
+
z-index: 5;
|
|
86
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
body{font-family:'Palatino Linotype','Book Antiqua',Palatino,FreeSerif,serif;line-height:1.5;color:#30404f;margin:0;padding:0}h1,h2,h3,h4,h5,h6{color:#123;font-weight:400;margin:0 0 1rem 0}.frontmatter{text-align:center;margin-top:2em}a{color:#08c;text-decoration:none}a:focus,a:hover{color:#005580;text-decoration:underline}table{width:100%;border:0}td.code,td.docs{width:50%;vertical-align:top;padding:1em 1em 1px 2em}td.code{background:#f5f5ff;overflow-x:hidden}code{font-size:.8em}td.docs code{background:#f8f8ff;border:1px solid #dedede}img{max-width:100%}pre code{display:block;line-height:1}pre code:hover{white-space:pre-wrap}.pilwrap{position:relative}.pilcrow{font:12px Arial;text-decoration:none;color:#454545;position:absolute;top:3px;left:-1.5em;padding:1px 2px;opacity:0}td.docs:hover .pilcrow{opacity:1}blockquote{border-left:4px solid #ddd;padding:0 1em;color:#777}.container{position:relative}.handler{width:5px;padding:0;cursor:col-resize;position:absolute;z-index:5}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// create a <table> of 2 columns; put <pre> in the right column and other elements in the left column
|
|
2
|
+
(d => {
|
|
3
|
+
// find the first <pre> and assume it to be the container all code blocks
|
|
4
|
+
const c1 = d.querySelector('pre')?.parentNode;
|
|
5
|
+
if (!c1) return;
|
|
6
|
+
c1.insertAdjacentHTML('afterend', '<div class="container"><div class="handler"></div><table><tbody><tr><td class="docs"><div class="pilwrap"><a class="pilcrow" href="#">¶</a></div></td><td class="code"></td></tr></tbody></table></div>');
|
|
7
|
+
// move <pre> into <tbody>'s second <td>, and everything else into first <td>
|
|
8
|
+
const c2 = c1.nextElementSibling.querySelector('tbody');
|
|
9
|
+
let c3 = c2.lastElementChild, c4 = c3.cloneNode(true), newRow = false;
|
|
10
|
+
while (true) {
|
|
11
|
+
const el = c1.firstElementChild;
|
|
12
|
+
if (!el) break;
|
|
13
|
+
if (el.tagName === 'PRE') {
|
|
14
|
+
c3.lastElementChild.append(el);
|
|
15
|
+
newRow = true;
|
|
16
|
+
} else {
|
|
17
|
+
if (newRow) {
|
|
18
|
+
c3 = c4.cloneNode(true);
|
|
19
|
+
c2.append(c3);
|
|
20
|
+
newRow = false;
|
|
21
|
+
}
|
|
22
|
+
c3.firstElementChild.append(el);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
c1.remove();
|
|
26
|
+
// if a cell contains plots, shift all code cells from there down by one row
|
|
27
|
+
for (let row of c2.rows) {
|
|
28
|
+
if (row.querySelector('td.docs img')) {
|
|
29
|
+
let prev = row.previousElementSibling;
|
|
30
|
+
if (!prev) continue;
|
|
31
|
+
// create a new row if necessary
|
|
32
|
+
if (c2.lastElementChild.cells[1].innerText !== '') {
|
|
33
|
+
c2.append(c4.cloneNode(true));
|
|
34
|
+
}
|
|
35
|
+
// move the last empty code cell before the previous code cell
|
|
36
|
+
prev.cells[0].after(c2.lastElementChild.cells[1]);
|
|
37
|
+
while (prev) {
|
|
38
|
+
const cells = prev.nextElementSibling?.cells;
|
|
39
|
+
if (!cells) break;
|
|
40
|
+
cells[0].after(prev.lastElementChild);
|
|
41
|
+
prev = prev.nextElementSibling;
|
|
42
|
+
}
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
[...c2.rows].forEach((row, i) => {
|
|
47
|
+
row.id = 'row' + (i + 1);
|
|
48
|
+
row.querySelector('.pilcrow').href = '#' + row.id;
|
|
49
|
+
});
|
|
50
|
+
})(document);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(e=>{const l=e.querySelector("pre")?.parentNode;if(!l)return;l.insertAdjacentHTML("afterend",'<div class="container"><div class="handler"></div><table><tbody><tr><td class="docs"><div class="pilwrap"><a class="pilcrow" href="#">¶</a></div></td><td class="code"></td></tr></tbody></table></div>');const t=l.nextElementSibling.querySelector("tbody");let n=t.lastElementChild,r=n.cloneNode(!0),i=!1;for(;;){const e=l.firstElementChild;if(!e)break;"PRE"===e.tagName?(n.lastElementChild.append(e),i=!0):(i&&(n=r.cloneNode(!0),t.append(n),i=!1),n.firstElementChild.append(e))}l.remove();for(let e of t.rows)if(e.querySelector("td.docs img")){let l=e.previousElementSibling;if(!l)continue;for(""!==t.lastElementChild.cells[1].innerText&&t.append(r.cloneNode(!0)),l.cells[0].after(t.lastElementChild.cells[1]);l;){const e=l.nextElementSibling?.cells;if(!e)break;e[0].after(l.lastElementChild),l=l.nextElementSibling}break}[...t.rows].forEach(((e,l)=>{e.id="row"+(l+1),e.querySelector(".pilcrow").href="#"+e.id}))})(document);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
jQuery.fn.disableTextSelect=function(){return this.each(function(){$(this).css({MozUserSelect:"none",webkitUserSelect:"none"}).attr("unselectable","on").bind("selectstart",function(){return false})})};jQuery.fn.enableTextSelect=function(){return this.each(function(){$(this).css({MozUserSelect:"",webkitUserSelect:""}).attr("unselectable","off").unbind("selectstart")})};$(document).ready(function(){var e=$("td.docs");var t=$("td.code");var n=$("div.handler");n.css("height",$("table").css("height"));n.css("left",t.offset().left);var r=parseInt(e.css("padding-right"));var i=parseInt(e.css("padding-left"));var s=parseInt(n.css("width"));n.mousedown(function(){$("body").disableTextSelect();$(document).bind("mousemove",function(o){var u=o.pageX-e.offset().left-r-i-.5*s;e.width(u);n.css("left",t.offset().left)}).mouseup(function(){$("body").enableTextSelect();$(document).unbind("mousemove")})});var o="both";$(document).keydown(function(r){if(r.which==84){switch(o){case"both":t.hide(500);n.hide();o="left";break;case"left":t.show(500);e.hide(500);o="right";break;case"right":t.show(500);e.show(500);n.show(500);o="both";break;default:break}}})});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
jQuery.fn.disableTextSelect=function(){return this.each((function(){$(this).css({MozUserSelect:"none",webkitUserSelect:"none"}).attr("unselectable","on").bind("selectstart",(function(){return!1}))}))},jQuery.fn.enableTextSelect=function(){return this.each((function(){$(this).css({MozUserSelect:"",webkitUserSelect:""}).attr("unselectable","off").unbind("selectstart")}))},$(document).ready((function(){var e=$("td.docs"),t=$("td.code"),s=$("div.handler");s.css("height",$("table").css("height")),s.css("left",t.offset().left);var n=parseInt(e.css("padding-right")),c=parseInt(e.css("padding-left")),o=parseInt(s.css("width"));s.mousedown((function(){$("body").disableTextSelect(),$(document).bind("mousemove",(function(i){var a=i.pageX-e.offset().left-n-c-.5*o;e.width(a),s.css("left",t.offset().left)})).mouseup((function(){$("body").enableTextSelect(),$(document).unbind("mousemove")}))}));var i="both";$(document).keydown((function(n){if(84==n.which)switch(i){case"both":t.hide(500),s.hide(),i="left";break;case"left":t.show(500),e.hide(500),i="right";break;case"right":t.show(500),e.show(500),s.show(500),i="both"}}))}));
|