@hyperbook/markdown 0.11.1 → 0.12.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/dist/assets/client.js +13 -0
- package/dist/assets/content.css +86 -3
- package/dist/index.js +123 -6
- package/dist/index.js.map +4 -4
- package/dist/rehypeQrCode.d.ts +5 -0
- package/package.json +3 -2
package/dist/assets/client.js
CHANGED
|
@@ -33,6 +33,17 @@ var hyperbook = (function () {
|
|
|
33
33
|
const tocDrawerEl = document.getElementById("toc-drawer");
|
|
34
34
|
tocDrawerEl.open = !tocDrawerEl.open;
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
function qrcodeOpen() {
|
|
38
|
+
const qrCodeDialog = document.getElementById("qrcode-dialog");
|
|
39
|
+
qrCodeDialog.showModal();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function qrcodeClose() {
|
|
43
|
+
const qrCodeDialog = document.getElementById("qrcode-dialog");
|
|
44
|
+
qrCodeDialog.close();
|
|
45
|
+
}
|
|
46
|
+
|
|
36
47
|
function navToggle() {
|
|
37
48
|
const navDrawerEl = document.getElementById("nav-drawer");
|
|
38
49
|
navDrawerEl.open = !navDrawerEl.open;
|
|
@@ -83,5 +94,7 @@ var hyperbook = (function () {
|
|
|
83
94
|
toggleBookmark,
|
|
84
95
|
navToggle,
|
|
85
96
|
tocToggle,
|
|
97
|
+
qrcodeOpen,
|
|
98
|
+
qrcodeClose,
|
|
86
99
|
};
|
|
87
100
|
})();
|
package/dist/assets/content.css
CHANGED
|
@@ -370,7 +370,8 @@ figure {
|
|
|
370
370
|
background-color: var(--color-text);
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
-
.hyperbook-markdown #toc-toggle
|
|
373
|
+
.hyperbook-markdown #toc-toggle,
|
|
374
|
+
.hyperbook-markdown #qrcode-open {
|
|
374
375
|
background: var(--color-background);
|
|
375
376
|
border-color: var(--color-nav-border);
|
|
376
377
|
cursor: pointer;
|
|
@@ -399,7 +400,84 @@ figure {
|
|
|
399
400
|
text-decoration: underline;
|
|
400
401
|
}
|
|
401
402
|
|
|
402
|
-
.hyperbook-markdown #
|
|
403
|
+
.hyperbook-markdown #qrcode-dialog {
|
|
404
|
+
background: var(--color-background);
|
|
405
|
+
border: 1px solid var(--color-brand);
|
|
406
|
+
width: 100%;
|
|
407
|
+
height: 100%;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
#qrcode-dialog .container {
|
|
411
|
+
position: absolute;
|
|
412
|
+
top: 0;
|
|
413
|
+
bottom: 0;
|
|
414
|
+
right: 0;
|
|
415
|
+
left: 0;
|
|
416
|
+
padding: 16px;
|
|
417
|
+
display: flex;
|
|
418
|
+
flex-direction: column;
|
|
419
|
+
align-items: center;
|
|
420
|
+
justify-content: center;
|
|
421
|
+
gap: 8px;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
#qrcode-dialog .name {
|
|
425
|
+
color: var(--color-text);
|
|
426
|
+
text-align: center;
|
|
427
|
+
font-size: 2rem;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
#qrcode-dialog .url {
|
|
431
|
+
color: var(--color-text);
|
|
432
|
+
text-align: center;
|
|
433
|
+
font-size: 1.25rem;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
#qrcode-dialog .close {
|
|
437
|
+
background: none;
|
|
438
|
+
border: none;
|
|
439
|
+
font-size: 2rem;
|
|
440
|
+
color: var(--color-text);
|
|
441
|
+
cursor: pointer;
|
|
442
|
+
position: absolute;
|
|
443
|
+
font: monospace;
|
|
444
|
+
top: 0px;
|
|
445
|
+
right: 0px;
|
|
446
|
+
width: 48px;
|
|
447
|
+
height: 48px;
|
|
448
|
+
display: flex;
|
|
449
|
+
justify-content: center;
|
|
450
|
+
align-items: center;
|
|
451
|
+
background: var(--color-background);
|
|
452
|
+
border-radius: 8px;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
#qrcode-dialog .close:hover .close-icon {
|
|
456
|
+
background-color: var(--color-brand);
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
.hyperbook-markdown #qrcode-dialog svg {
|
|
460
|
+
width: 100%;
|
|
461
|
+
max-width: 512px;
|
|
462
|
+
margin: 0 auto;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
.hyperbook-markdown .close-icon {
|
|
466
|
+
background-color: var(--color-text);
|
|
467
|
+
width: 32px;
|
|
468
|
+
height: 32px;
|
|
469
|
+
mask-image: url('data:image/svg+xml,<svg width="32px" height="32px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.29289 5.29289C5.68342 4.90237 6.31658 4.90237 6.70711 5.29289L12 10.5858L17.2929 5.29289C17.6834 4.90237 18.3166 4.90237 18.7071 5.29289C19.0976 5.68342 19.0976 6.31658 18.7071 6.70711L13.4142 12L18.7071 17.2929C19.0976 17.6834 19.0976 18.3166 18.7071 18.7071C18.3166 19.0976 17.6834 19.0976 17.2929 18.7071L12 13.4142L6.70711 18.7071C6.31658 19.0976 5.68342 19.0976 5.29289 18.7071C4.90237 18.3166 4.90237 17.6834 5.29289 17.2929L10.5858 12L5.29289 6.70711C4.90237 6.31658 4.90237 5.68342 5.29289 5.29289Z" fill="%230F1729"/></svg>');
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
.hyperbook-markdown .qrcode-icon {
|
|
473
|
+
background-color: var(--color-text);
|
|
474
|
+
width: 32px;
|
|
475
|
+
height: 32px;
|
|
476
|
+
mask-image: url('data:image/svg+xml,<svg width="32px" height="32px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M3 9h6V3H3zm1-5h4v4H4zm1 1h2v2H5zm10 4h6V3h-6zm1-5h4v4h-4zm1 1h2v2h-2zM3 21h6v-6H3zm1-5h4v4H4zm1 1h2v2H5zm15 2h1v2h-2v-3h1zm0-3h1v1h-1zm0-1v1h-1v-1zm-10 2h1v4h-1v-4zm-4-7v2H4v-1H3v-1h3zm4-3h1v1h-1zm3-3v2h-1V3h2v1zm-3 0h1v1h-1zm10 8h1v2h-2v-1h1zm-1-2v1h-2v2h-2v-1h1v-2h3zm-7 4h-1v-1h-1v-1h2v2zm6 2h1v1h-1zm2-5v1h-1v-1zm-9 3v1h-1v-1zm6 5h1v2h-2v-2zm-3 0h1v1h-1v1h-2v-1h1v-1zm0-1v-1h2v1zm0-5h1v3h-1v1h-1v1h-1v-2h-1v-1h3v-1h-1v-1zm-9 0v1H4v-1zm12 4h-1v-1h1zm1-2h-2v-1h2zM8 10h1v1H8v1h1v2H8v-1H7v1H6v-2h1v-2zm3 0V8h3v3h-2v-1h1V9h-1v1zm0-4h1v1h-1zm-1 4h1v1h-1zm3-3V6h1v1z"/><path fill="none" d="M0 0h24v24H0z"/></svg>');
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
.hyperbook-markdown #toc-toggle,
|
|
480
|
+
.hyperbook-markdown #qrcode-open {
|
|
403
481
|
position: fixed;
|
|
404
482
|
padding: 4px;
|
|
405
483
|
top: 90px;
|
|
@@ -413,7 +491,12 @@ figure {
|
|
|
413
491
|
z-index: 1000;
|
|
414
492
|
}
|
|
415
493
|
|
|
416
|
-
.hyperbook-markdown #
|
|
494
|
+
.hyperbook-markdown #qrcode-open {
|
|
495
|
+
top: 140px;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.hyperbook-markdown #toc-toggle:hover,
|
|
499
|
+
.hyperbook-markdown #qrcode-toggle:hover {
|
|
417
500
|
opacity: 1;
|
|
418
501
|
}
|
|
419
502
|
|
package/dist/index.js
CHANGED
|
@@ -5186,7 +5186,7 @@ var require_qrcode = __commonJS({
|
|
|
5186
5186
|
this.length++;
|
|
5187
5187
|
} };
|
|
5188
5188
|
var QRCodeLimitLength = [[17, 14, 11, 7], [32, 26, 20, 14], [53, 42, 32, 24], [78, 62, 46, 34], [106, 84, 60, 44], [134, 106, 74, 58], [154, 122, 86, 64], [192, 152, 108, 84], [230, 180, 130, 98], [271, 213, 151, 119], [321, 251, 177, 137], [367, 287, 203, 155], [425, 331, 241, 177], [458, 362, 258, 194], [520, 412, 292, 220], [586, 450, 322, 250], [644, 504, 364, 280], [718, 560, 394, 310], [792, 624, 442, 338], [858, 666, 482, 382], [929, 711, 509, 403], [1003, 779, 565, 439], [1091, 857, 611, 461], [1171, 911, 661, 511], [1273, 997, 715, 535], [1367, 1059, 751, 593], [1465, 1125, 805, 625], [1528, 1190, 868, 658], [1628, 1264, 908, 698], [1732, 1370, 982, 742], [1840, 1452, 1030, 790], [1952, 1538, 1112, 842], [2068, 1628, 1168, 898], [2188, 1722, 1228, 958], [2303, 1809, 1283, 983], [2431, 1911, 1351, 1051], [2563, 1989, 1423, 1093], [2699, 2099, 1499, 1139], [2809, 2213, 1579, 1219], [2953, 2331, 1663, 1273]];
|
|
5189
|
-
function
|
|
5189
|
+
function QRCode3(options) {
|
|
5190
5190
|
var instance = this;
|
|
5191
5191
|
this.options = {
|
|
5192
5192
|
padding: 4,
|
|
@@ -5279,7 +5279,7 @@ var require_qrcode = __commonJS({
|
|
|
5279
5279
|
this.qrcode.addData(content5);
|
|
5280
5280
|
this.qrcode.make();
|
|
5281
5281
|
}
|
|
5282
|
-
|
|
5282
|
+
QRCode3.prototype.svg = function(opt) {
|
|
5283
5283
|
var options = this.options || {};
|
|
5284
5284
|
var modules = this.qrcode.modules;
|
|
5285
5285
|
if (typeof opt == "undefined") {
|
|
@@ -5360,7 +5360,7 @@ var require_qrcode = __commonJS({
|
|
|
5360
5360
|
}
|
|
5361
5361
|
return svg5;
|
|
5362
5362
|
};
|
|
5363
|
-
|
|
5363
|
+
QRCode3.prototype.save = function(file, callback) {
|
|
5364
5364
|
var data = this.svg();
|
|
5365
5365
|
if (typeof callback != "function") {
|
|
5366
5366
|
callback = function(error, result) {
|
|
@@ -5374,7 +5374,7 @@ var require_qrcode = __commonJS({
|
|
|
5374
5374
|
}
|
|
5375
5375
|
};
|
|
5376
5376
|
if (typeof module != "undefined") {
|
|
5377
|
-
module.exports =
|
|
5377
|
+
module.exports = QRCode3;
|
|
5378
5378
|
}
|
|
5379
5379
|
}
|
|
5380
5380
|
});
|
|
@@ -63433,6 +63433,9 @@ var rehypeTableOfContents_default = (ctx) => () => {
|
|
|
63433
63433
|
return (tree, file) => {
|
|
63434
63434
|
const headings = file.data.headings || [];
|
|
63435
63435
|
const originalChildren = tree.children;
|
|
63436
|
+
if (!showToc) {
|
|
63437
|
+
return;
|
|
63438
|
+
}
|
|
63436
63439
|
const tocSidebar = [
|
|
63437
63440
|
{
|
|
63438
63441
|
type: "element",
|
|
@@ -64243,7 +64246,7 @@ var rehypeHtmlStructure_default = (ctx) => () => {
|
|
|
64243
64246
|
children: [
|
|
64244
64247
|
{
|
|
64245
64248
|
type: "text",
|
|
64246
|
-
value: `${currentPage?.name} - ${config2.name}`
|
|
64249
|
+
value: currentPage?.name ? `${currentPage?.name} - ${config2.name}` : config2.name
|
|
64247
64250
|
}
|
|
64248
64251
|
]
|
|
64249
64252
|
},
|
|
@@ -64252,7 +64255,7 @@ var rehypeHtmlStructure_default = (ctx) => () => {
|
|
|
64252
64255
|
tagName: "meta",
|
|
64253
64256
|
properties: {
|
|
64254
64257
|
property: "og:title",
|
|
64255
|
-
|
|
64258
|
+
value: currentPage?.name ? `${currentPage?.name} - ${config2.name}` : config2.name
|
|
64256
64259
|
},
|
|
64257
64260
|
children: []
|
|
64258
64261
|
},
|
|
@@ -72049,6 +72052,119 @@ var remarkDirectivePagelist_default = (ctx) => () => {
|
|
|
72049
72052
|
};
|
|
72050
72053
|
};
|
|
72051
72054
|
|
|
72055
|
+
// src/rehypeQrCode.ts
|
|
72056
|
+
var import_qrcode_svg2 = __toESM(require_qrcode(), 1);
|
|
72057
|
+
var rehypeQrCode_default = (ctx) => () => {
|
|
72058
|
+
const qrcode = ctx.config.qrcode || ctx.navigation.current?.qrcode || true;
|
|
72059
|
+
return (tree, file) => {
|
|
72060
|
+
const originalChildren = tree.children;
|
|
72061
|
+
if (!qrcode || !ctx.navigation.current?.href) {
|
|
72062
|
+
return;
|
|
72063
|
+
}
|
|
72064
|
+
const qr = new import_qrcode_svg2.default({
|
|
72065
|
+
content: ctx.navigation.current.href,
|
|
72066
|
+
padding: 0,
|
|
72067
|
+
width: 512,
|
|
72068
|
+
height: 512,
|
|
72069
|
+
color: "var(--color-text)",
|
|
72070
|
+
container: "svg-viewbox",
|
|
72071
|
+
background: "var(--color-background)",
|
|
72072
|
+
ecl: "M"
|
|
72073
|
+
}).svg();
|
|
72074
|
+
const qrcodeDialog = [
|
|
72075
|
+
{
|
|
72076
|
+
type: "element",
|
|
72077
|
+
tagName: "button",
|
|
72078
|
+
properties: {
|
|
72079
|
+
id: "qrcode-open",
|
|
72080
|
+
onclick: "hyperbook.qrcodeOpen()",
|
|
72081
|
+
title: "QR-Code"
|
|
72082
|
+
},
|
|
72083
|
+
children: [
|
|
72084
|
+
{
|
|
72085
|
+
type: "element",
|
|
72086
|
+
tagName: "div",
|
|
72087
|
+
properties: {
|
|
72088
|
+
class: "qrcode-icon"
|
|
72089
|
+
},
|
|
72090
|
+
children: []
|
|
72091
|
+
}
|
|
72092
|
+
]
|
|
72093
|
+
},
|
|
72094
|
+
{
|
|
72095
|
+
type: "element",
|
|
72096
|
+
tagName: "dialog",
|
|
72097
|
+
properties: {
|
|
72098
|
+
id: "qrcode-dialog"
|
|
72099
|
+
},
|
|
72100
|
+
children: [
|
|
72101
|
+
{
|
|
72102
|
+
type: "element",
|
|
72103
|
+
tagName: "div",
|
|
72104
|
+
properties: {
|
|
72105
|
+
class: "container"
|
|
72106
|
+
},
|
|
72107
|
+
children: [
|
|
72108
|
+
{
|
|
72109
|
+
type: "element",
|
|
72110
|
+
tagName: "div",
|
|
72111
|
+
properties: {
|
|
72112
|
+
class: "name"
|
|
72113
|
+
},
|
|
72114
|
+
children: [
|
|
72115
|
+
{
|
|
72116
|
+
type: "text",
|
|
72117
|
+
value: ctx.navigation.current.name || ctx.config.name
|
|
72118
|
+
}
|
|
72119
|
+
]
|
|
72120
|
+
},
|
|
72121
|
+
...fromHtml(qr).children,
|
|
72122
|
+
{
|
|
72123
|
+
type: "element",
|
|
72124
|
+
tagName: "div",
|
|
72125
|
+
properties: {
|
|
72126
|
+
class: "url"
|
|
72127
|
+
},
|
|
72128
|
+
children: [
|
|
72129
|
+
{
|
|
72130
|
+
type: "text",
|
|
72131
|
+
value: `${ctx.makeUrl(
|
|
72132
|
+
ctx.navigation.current?.href || "",
|
|
72133
|
+
"public"
|
|
72134
|
+
)}`
|
|
72135
|
+
}
|
|
72136
|
+
]
|
|
72137
|
+
}
|
|
72138
|
+
]
|
|
72139
|
+
},
|
|
72140
|
+
{
|
|
72141
|
+
type: "element",
|
|
72142
|
+
tagName: "button",
|
|
72143
|
+
properties: {
|
|
72144
|
+
class: "close",
|
|
72145
|
+
onclick: "hyperbook.qrcodeClose()"
|
|
72146
|
+
},
|
|
72147
|
+
children: [
|
|
72148
|
+
{
|
|
72149
|
+
type: "element",
|
|
72150
|
+
tagName: "div",
|
|
72151
|
+
properties: {
|
|
72152
|
+
class: "close-icon"
|
|
72153
|
+
},
|
|
72154
|
+
children: []
|
|
72155
|
+
}
|
|
72156
|
+
]
|
|
72157
|
+
}
|
|
72158
|
+
]
|
|
72159
|
+
}
|
|
72160
|
+
];
|
|
72161
|
+
if (originalChildren[0].type === "element" && originalChildren[0].tagName === "div") {
|
|
72162
|
+
originalChildren[0].children.push(...qrcodeDialog);
|
|
72163
|
+
}
|
|
72164
|
+
tree.children = originalChildren;
|
|
72165
|
+
};
|
|
72166
|
+
};
|
|
72167
|
+
|
|
72052
72168
|
// src/process.ts
|
|
72053
72169
|
var remark = (ctx) => {
|
|
72054
72170
|
const remarkPlugins = [
|
|
@@ -72091,6 +72207,7 @@ var remark = (ctx) => {
|
|
|
72091
72207
|
];
|
|
72092
72208
|
const rehypePlugins = [
|
|
72093
72209
|
rehypeTableOfContents_default(ctx),
|
|
72210
|
+
rehypeQrCode_default(ctx),
|
|
72094
72211
|
rehypeKatex,
|
|
72095
72212
|
[
|
|
72096
72213
|
src_default,
|