hyperbook 0.71.5 → 0.72.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.
@@ -179,6 +179,68 @@ var hyperbook = (function () {
179
179
  qrCodeDialog.close();
180
180
  }
181
181
 
182
+ /**
183
+ * Open the share dialog.
184
+ */
185
+ function shareOpen() {
186
+ const shareDialog = document.getElementById("share-dialog");
187
+ shareUpdatePreview();
188
+ shareDialog.showModal();
189
+ }
190
+
191
+ /**
192
+ * Close the share dialog.
193
+ */
194
+ function shareClose() {
195
+ const shareDialog = document.getElementById("share-dialog");
196
+ shareDialog.close();
197
+ }
198
+
199
+ /**
200
+ * Update the URL preview in the share dialog.
201
+ */
202
+ function shareUpdatePreview() {
203
+ const standaloneCheckbox = document.getElementById("share-standalone-checkbox");
204
+ const sectionCheckboxes = document.querySelectorAll("#share-dialog input[data-anchor]");
205
+ const previewEl = document.getElementById("share-url-preview");
206
+
207
+ const baseUrl = window.location.origin + window.location.pathname;
208
+ const params = new URLSearchParams();
209
+
210
+ if (standaloneCheckbox && standaloneCheckbox.checked) {
211
+ params.append("standalone", "true");
212
+ }
213
+
214
+ const selectedSections = Array.from(sectionCheckboxes)
215
+ .filter(cb => cb.checked)
216
+ .map(cb => cb.getAttribute("data-anchor"));
217
+
218
+ if (selectedSections.length > 0) {
219
+ params.append("sections", selectedSections.join(","));
220
+ }
221
+
222
+ const finalUrl = params.toString() ? `${baseUrl}?${params.toString()}` : baseUrl;
223
+ previewEl.textContent = finalUrl;
224
+ }
225
+
226
+ /**
227
+ * Copy the shareable URL to clipboard.
228
+ */
229
+ function shareCopyUrl() {
230
+ const previewEl = document.getElementById("share-url-preview");
231
+ const url = previewEl.textContent;
232
+
233
+ navigator.clipboard.writeText(url).then(() => {
234
+ const button = document.querySelector("#share-dialog .copy-button");
235
+ const originalText = button.textContent;
236
+ button.textContent = window.i18n.get("share-dialog-url-copied");
237
+
238
+ setTimeout(() => {
239
+ button.textContent = originalText;
240
+ }, 2000);
241
+ });
242
+ }
243
+
182
244
  /**
183
245
  * Toggle the navigation drawer.
184
246
  */
@@ -274,6 +336,103 @@ var hyperbook = (function () {
274
336
  initBookmarks(root);
275
337
  }
276
338
 
339
+ /**
340
+ * Hide TOC toggle button when sections are filtered
341
+ */
342
+ function hideTocWhenFiltered() {
343
+ const tocToggle = document.getElementById('toc-toggle');
344
+
345
+ if (tocToggle) {
346
+ tocToggle.style.display = 'none';
347
+ }
348
+ }
349
+
350
+ // Filter sections based on query parameter
351
+ function filterSections() {
352
+ const urlParams = new URLSearchParams(window.location.search);
353
+ const sectionsParam = urlParams.get('sections');
354
+
355
+ if (!sectionsParam) {
356
+ return; // No filtering needed
357
+ }
358
+
359
+ // Parse sections parameter (comma-separated list of IDs)
360
+ const sectionIds = sectionsParam.split(',').map(id => id.trim()).filter(id => id);
361
+
362
+ if (sectionIds.length === 0) {
363
+ return; // No valid IDs provided
364
+ }
365
+
366
+ // Get all headings in the document
367
+ const allHeadings = document.querySelectorAll('h1, h2, h3, h4, h5, h6');
368
+ const headingsArray = Array.from(allHeadings);
369
+
370
+ // Build a map of which elements should be visible
371
+ const visibleElements = new Set();
372
+
373
+ sectionIds.forEach(sectionId => {
374
+ // Find the heading with this ID
375
+ const heading = document.getElementById(sectionId);
376
+ if (!heading) {
377
+ return; // ID not found
378
+ }
379
+
380
+ // Get the heading level (h1 = 1, h2 = 2, etc.)
381
+ const headingLevel = parseInt(heading.tagName.substring(1));
382
+
383
+ // Mark this heading as visible
384
+ visibleElements.add(heading);
385
+
386
+ // Find the index of this heading
387
+ const headingIndex = headingsArray.indexOf(heading);
388
+ if (headingIndex === -1) {
389
+ return;
390
+ }
391
+
392
+ // Collect all elements until the next heading of the same or higher level
393
+ let currentElement = heading.nextElementSibling;
394
+
395
+ while (currentElement) {
396
+ // Check if this is a heading
397
+ const isHeading = /^H[1-6]$/.test(currentElement.tagName);
398
+
399
+ if (isHeading) {
400
+ const currentLevel = parseInt(currentElement.tagName.substring(1));
401
+
402
+ // Stop if we hit a heading of the same or higher level (lower number)
403
+ if (currentLevel <= headingLevel) {
404
+ break;
405
+ }
406
+
407
+ // Include lower-level headings (subsections)
408
+ visibleElements.add(currentElement);
409
+ } else {
410
+ // Include non-heading elements
411
+ visibleElements.add(currentElement);
412
+ }
413
+
414
+ currentElement = currentElement.nextElementSibling;
415
+ }
416
+ });
417
+
418
+ // Hide all elements that are not in visibleElements
419
+ const markdownDiv = document.querySelector('main article .hyperbook-markdown');
420
+ if (markdownDiv) {
421
+ Array.from(markdownDiv.children).forEach(element => {
422
+ // Don't hide UI elements (floating buttons container, side drawers)
423
+ const isUIElement = element.id === 'floating-buttons-container' ||
424
+ element.tagName === 'SIDE-DRAWER';
425
+
426
+ if (!visibleElements.has(element) && !isUIElement) {
427
+ element.style.display = 'none';
428
+ }
429
+ });
430
+
431
+ // Hide TOC toggle when sections are filtered
432
+ hideTocWhenFiltered();
433
+ }
434
+ }
435
+
277
436
  // Check for standalone layout URL parameter or iframe context
278
437
  function checkStandaloneMode() {
279
438
  // Check if explicitly requested via URL parameter
@@ -307,6 +466,7 @@ var hyperbook = (function () {
307
466
  document.addEventListener("DOMContentLoaded", () => {
308
467
  init(document);
309
468
  checkStandaloneMode();
469
+ filterSections();
310
470
  });
311
471
 
312
472
  // Observe for new elements added to the DOM
@@ -332,6 +492,10 @@ var hyperbook = (function () {
332
492
  search,
333
493
  qrcodeOpen,
334
494
  qrcodeClose,
495
+ shareOpen,
496
+ shareClose,
497
+ shareUpdatePreview,
498
+ shareCopyUrl,
335
499
  init,
336
500
  };
337
501
  })();
@@ -469,13 +469,17 @@ figure {
469
469
  text-decoration: underline;
470
470
  }
471
471
 
472
- .hyperbook-markdown #qrcode-dialog {
472
+ #qrcode-dialog {
473
473
  background: var(--color-background);
474
474
  border: 1px solid var(--color-brand);
475
475
  width: 100%;
476
476
  height: 100%;
477
477
  }
478
478
 
479
+ #qrcode-dialog::backdrop {
480
+ background: rgba(0, 0, 0, 0.5);
481
+ }
482
+
479
483
  #qrcode-dialog .container {
480
484
  position: absolute;
481
485
  top: 0;
@@ -524,13 +528,13 @@ figure {
524
528
  background-color: var(--color-brand);
525
529
  }
526
530
 
527
- .hyperbook-markdown #qrcode-dialog .make-qrcode {
531
+ #qrcode-dialog .make-qrcode {
528
532
  width: 100%;
529
533
  max-width: 512px;
530
534
  margin: 0 auto;
531
535
  }
532
536
 
533
- .hyperbook-markdown #qrcode-dialog svg {
537
+ #qrcode-dialog svg {
534
538
  width: 100%;
535
539
  }
536
540
 
@@ -548,23 +552,25 @@ figure {
548
552
  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>');
549
553
  }
550
554
 
551
- .hyperbook-markdown #toc-toggle,
552
- .hyperbook-markdown #qrcode-open {
555
+ .floating-buttons-container {
553
556
  position: fixed;
554
- padding: 4px;
555
557
  top: 90px;
556
558
  right: 20px;
559
+ display: flex;
560
+ flex-direction: column;
561
+ gap: 10px;
562
+ z-index: 1000;
563
+ }
564
+
565
+ #toc-toggle,
566
+ #qrcode-open {
567
+ padding: 4px;
557
568
  border-radius: 50%;
558
569
  height: 40px;
559
570
  width: 40px;
560
571
  border-style: solid;
561
572
  border-width: 1px;
562
573
  opacity: 0.7;
563
- z-index: 1000;
564
- }
565
-
566
- .hyperbook-markdown #qrcode-open {
567
- top: 140px;
568
574
  }
569
575
 
570
576
  .hyperbook-markdown #toc-toggle:hover,
@@ -587,3 +593,189 @@ figure {
587
593
  margin: 2px 3px;
588
594
  transition: 0.4s;
589
595
  }
596
+
597
+ /* Share button and dialog styles */
598
+ #share-button {
599
+ background: none;
600
+ border: none;
601
+ cursor: pointer;
602
+ margin-right: 16px;
603
+ padding: 8px;
604
+ line-height: 1;
605
+ display: flex;
606
+ align-items: center;
607
+ justify-content: center;
608
+ }
609
+
610
+ #share-button:hover {
611
+ opacity: 0.8;
612
+ }
613
+
614
+ .share-icon {
615
+ background-color: var(--color-brand-text);
616
+ width: 24px;
617
+ height: 24px;
618
+ mask-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></svg>');
619
+ mask-size: contain;
620
+ mask-repeat: no-repeat;
621
+ mask-position: center;
622
+ }
623
+
624
+ header.inverted .share-icon {
625
+ background-color: var(--color-brand);
626
+ }
627
+
628
+ #share-dialog {
629
+ background: var(--color-background);
630
+ border: 1px solid var(--color-brand);
631
+ max-width: 600px;
632
+ max-height: 80vh;
633
+ padding: 0;
634
+ color: var(--color-text);
635
+ }
636
+
637
+ #share-dialog::backdrop {
638
+ background: rgba(0, 0, 0, 0.5);
639
+ }
640
+
641
+ #share-dialog .container {
642
+ padding: 24px;
643
+ display: flex;
644
+ flex-direction: column;
645
+ gap: 16px;
646
+ max-height: calc(80vh - 48px);
647
+ overflow-y: auto;
648
+ }
649
+
650
+ #share-dialog .title {
651
+ color: var(--color-text);
652
+ font-size: 1.5rem;
653
+ margin: 0;
654
+ }
655
+
656
+ #share-dialog .standalone-option {
657
+ display: flex;
658
+ align-items: center;
659
+ gap: 8px;
660
+ color: var(--color-text);
661
+ cursor: pointer;
662
+ font-size: 1rem;
663
+ padding: 8px;
664
+ background: var(--color-nav);
665
+ border-radius: 4px;
666
+ }
667
+
668
+ #share-dialog .sections-title {
669
+ color: var(--color-text);
670
+ font-size: 1.1rem;
671
+ margin: 8px 0 4px 0;
672
+ }
673
+
674
+ #share-dialog .sections-list {
675
+ display: flex;
676
+ flex-direction: column;
677
+ gap: 4px;
678
+ max-height: 300px;
679
+ overflow-y: auto;
680
+ border: 1px solid var(--color-spacer);
681
+ border-radius: 4px;
682
+ padding: 8px;
683
+ }
684
+
685
+ #share-dialog .heading-item {
686
+ display: flex;
687
+ align-items: center;
688
+ gap: 8px;
689
+ color: var(--color-text);
690
+ cursor: pointer;
691
+ padding: 4px 8px;
692
+ border-radius: 4px;
693
+ }
694
+
695
+ #share-dialog .heading-item:hover {
696
+ background: var(--color-nav);
697
+ }
698
+
699
+ #share-dialog .heading-item.level-1 {
700
+ font-weight: bold;
701
+ padding-left: 8px;
702
+ }
703
+
704
+ #share-dialog .heading-item.level-2 {
705
+ padding-left: 24px;
706
+ }
707
+
708
+ #share-dialog .heading-item.level-3 {
709
+ padding-left: 40px;
710
+ font-size: 0.95rem;
711
+ }
712
+
713
+ #share-dialog .heading-item.level-4 {
714
+ padding-left: 56px;
715
+ font-size: 0.9rem;
716
+ }
717
+
718
+ #share-dialog .heading-item.level-5 {
719
+ padding-left: 72px;
720
+ font-size: 0.85rem;
721
+ }
722
+
723
+ #share-dialog .heading-item.level-6 {
724
+ padding-left: 88px;
725
+ font-size: 0.8rem;
726
+ }
727
+
728
+ #share-dialog .url-preview {
729
+ background: var(--color-nav);
730
+ color: var(--color-text);
731
+ padding: 12px;
732
+ border-radius: 4px;
733
+ font-family: monospace;
734
+ font-size: 0.9rem;
735
+ word-break: break-all;
736
+ min-height: 40px;
737
+ }
738
+
739
+ #share-dialog .copy-button {
740
+ background: var(--color-brand);
741
+ color: var(--color-brand-text);
742
+ border: none;
743
+ padding: 12px 24px;
744
+ border-radius: 4px;
745
+ cursor: pointer;
746
+ font-size: 1rem;
747
+ font-weight: bold;
748
+ transition: opacity 0.2s;
749
+ }
750
+
751
+ #share-dialog .copy-button:hover {
752
+ opacity: 0.9;
753
+ }
754
+
755
+ #share-dialog .close {
756
+ background: none;
757
+ border: none;
758
+ font-size: 2rem;
759
+ color: var(--color-text);
760
+ cursor: pointer;
761
+ position: absolute;
762
+ top: 0px;
763
+ right: 0px;
764
+ width: 48px;
765
+ height: 48px;
766
+ display: flex;
767
+ justify-content: center;
768
+ align-items: center;
769
+ border-radius: 8px;
770
+ }
771
+
772
+ #share-dialog .close:hover .close-icon {
773
+ background-color: var(--color-brand);
774
+ }
775
+
776
+ #share-dialog .close .close-icon {
777
+ background-color: var(--color-text);
778
+ width: 32px;
779
+ height: 32px;
780
+ 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 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>');
781
+ }
@@ -964,6 +964,8 @@ var multievent = {
964
964
  }
965
965
 
966
966
  SK[clNr].style.display = "block";
967
+ SK[clNr].style.visibility = "visible";
968
+ SK[clNr].style.opacity = "1";
967
969
 
968
970
  // Add event listeners to save state on changes
969
971
  var allInputs = SK[clNr].getElementsByTagName("input");
@@ -8,6 +8,7 @@
8
8
  }
9
9
 
10
10
  .directive-multievent {
11
+ transition: opacity 0.2s ease-in;
11
12
 
12
13
  .MECheckbox:not(first-child),
13
14
  .MERadio:not(first-child) {
package/dist/index.js CHANGED
@@ -155917,6 +155917,12 @@ var en_default = {
155917
155917
  "slideshow-next": "Next",
155918
155918
  "slideshow-jump-to": "Jump to {{index}}",
155919
155919
  "toggle-bookmark": "Toggle Bookmark",
155920
+ "shell-share": "Share",
155921
+ "share-dialog-title": "Create Shareable URL",
155922
+ "share-dialog-standalone": "Standalone Mode",
155923
+ "share-dialog-select-sections": "Select Sections",
155924
+ "share-dialog-copy-url": "Copy Shareable URL",
155925
+ "share-dialog-url-copied": "URL copied to clipboard!",
155920
155926
  "webide-code-preview": "Code Preview",
155921
155927
  "webide-html": "HTML",
155922
155928
  "webide-css": "CSS",
@@ -155970,6 +155976,12 @@ var de_default = {
155970
155976
  "slideshow-next": "Weiter",
155971
155977
  "slideshow-jump-to": "Springe zu {{index}}",
155972
155978
  "toggle-bookmark": "Lesezeichen umschalten",
155979
+ "shell-share": "Teilen",
155980
+ "share-dialog-title": "Teilbare URL erstellen",
155981
+ "share-dialog-standalone": "Standalone-Modus",
155982
+ "share-dialog-select-sections": "Abschnitte ausw\xE4hlen",
155983
+ "share-dialog-copy-url": "Teilbare URL kopieren",
155984
+ "share-dialog-url-copied": "URL in Zwischenablage kopiert!",
155973
155985
  "webide-code-preview": "Code-Vorschau",
155974
155986
  "webide-html": "HTML",
155975
155987
  "webide-css": "CSS",
@@ -156132,105 +156144,115 @@ var rehypeTableOfContents_default = (ctx) => () => {
156132
156144
  return (tree, file) => {
156133
156145
  const headings = file.data.headings || [];
156134
156146
  const originalChildren = tree.children;
156135
- const tocSidebar = [
156136
- {
156137
- type: "element",
156138
- tagName: "button",
156139
- properties: {
156140
- id: "toc-toggle",
156141
- onclick: "hyperbook.tocToggle()",
156142
- title: i18n.get("table-of-contents")
156147
+ const tocButton = {
156148
+ type: "element",
156149
+ tagName: "button",
156150
+ properties: {
156151
+ id: "toc-toggle",
156152
+ onclick: "hyperbook.tocToggle()",
156153
+ title: i18n.get("table-of-contents")
156154
+ },
156155
+ children: [
156156
+ {
156157
+ type: "element",
156158
+ tagName: "div",
156159
+ properties: {
156160
+ class: "bar1"
156161
+ },
156162
+ children: []
156143
156163
  },
156144
- children: [
156145
- {
156146
- type: "element",
156147
- tagName: "div",
156148
- properties: {
156149
- class: "bar1"
156150
- },
156151
- children: []
156164
+ {
156165
+ type: "element",
156166
+ tagName: "div",
156167
+ properties: {
156168
+ class: "bar2"
156152
156169
  },
156153
- {
156154
- type: "element",
156155
- tagName: "div",
156156
- properties: {
156157
- class: "bar2"
156158
- },
156159
- children: []
156170
+ children: []
156171
+ },
156172
+ {
156173
+ type: "element",
156174
+ tagName: "div",
156175
+ properties: {
156176
+ class: "bar3"
156160
156177
  },
156161
- {
156162
- type: "element",
156163
- tagName: "div",
156164
- properties: {
156165
- class: "bar3"
156166
- },
156167
- children: []
156178
+ children: []
156179
+ },
156180
+ {
156181
+ type: "element",
156182
+ tagName: "div",
156183
+ properties: {
156184
+ class: "bar4"
156168
156185
  },
156169
- {
156170
- type: "element",
156171
- tagName: "div",
156172
- properties: {
156173
- class: "bar4"
156174
- },
156175
- children: []
156176
- }
156177
- ]
156186
+ children: []
156187
+ }
156188
+ ]
156189
+ };
156190
+ const tocDrawer = {
156191
+ type: "element",
156192
+ tagName: "side-drawer",
156193
+ properties: {
156194
+ id: "toc-drawer",
156195
+ right: true
156178
156196
  },
156197
+ children: [
156198
+ {
156199
+ type: "element",
156200
+ tagName: "div",
156201
+ properties: {
156202
+ class: "toc-drawer-content"
156203
+ },
156204
+ children: [
156205
+ {
156206
+ type: "element",
156207
+ tagName: "nav",
156208
+ properties: {
156209
+ class: "toc"
156210
+ },
156211
+ children: [
156212
+ {
156213
+ type: "element",
156214
+ tagName: "ul",
156215
+ properties: {},
156216
+ children: headings.map((heading3) => ({
156217
+ type: "element",
156218
+ tagName: "li",
156219
+ properties: {
156220
+ class: `level-${heading3.level}`
156221
+ },
156222
+ children: [
156223
+ {
156224
+ type: "element",
156225
+ tagName: "a",
156226
+ properties: {
156227
+ href: `#${heading3.anchor}`
156228
+ },
156229
+ children: [
156230
+ {
156231
+ type: "text",
156232
+ value: heading3.label
156233
+ }
156234
+ ]
156235
+ }
156236
+ ]
156237
+ }))
156238
+ }
156239
+ ]
156240
+ }
156241
+ ]
156242
+ }
156243
+ ]
156244
+ };
156245
+ const tocSidebar = [
156179
156246
  {
156180
156247
  type: "element",
156181
- tagName: "side-drawer",
156248
+ tagName: "div",
156182
156249
  properties: {
156183
- id: "toc-drawer",
156184
- right: true
156250
+ class: "floating-buttons-container",
156251
+ id: "floating-buttons-container"
156185
156252
  },
156186
- children: [
156187
- {
156188
- type: "element",
156189
- tagName: "div",
156190
- properties: {
156191
- class: "toc-drawer-content"
156192
- },
156193
- children: [
156194
- {
156195
- type: "element",
156196
- tagName: "nav",
156197
- properties: {
156198
- class: "toc"
156199
- },
156200
- children: [
156201
- {
156202
- type: "element",
156203
- tagName: "ul",
156204
- properties: {},
156205
- children: headings.map((heading3) => ({
156206
- type: "element",
156207
- tagName: "li",
156208
- properties: {
156209
- class: `level-${heading3.level}`
156210
- },
156211
- children: [
156212
- {
156213
- type: "element",
156214
- tagName: "a",
156215
- properties: {
156216
- href: `#${heading3.anchor}`
156217
- },
156218
- children: [
156219
- {
156220
- type: "text",
156221
- value: heading3.label
156222
- }
156223
- ]
156224
- }
156225
- ]
156226
- }))
156227
- }
156228
- ]
156229
- }
156230
- ]
156231
- }
156232
- ]
156233
- }
156253
+ children: [tocButton]
156254
+ },
156255
+ tocDrawer
156234
156256
  ];
156235
156257
  tree.children = [
156236
156258
  {
@@ -158033,6 +158055,26 @@ var makeHeaderElements = (ctx) => {
158033
158055
  ]
158034
158056
  });
158035
158057
  }
158058
+ elements.push({
158059
+ type: "element",
158060
+ tagName: "button",
158061
+ properties: {
158062
+ id: "share-button",
158063
+ class: "icon-button",
158064
+ title: i18n.get("shell-share"),
158065
+ onclick: "hyperbook.shareOpen()"
158066
+ },
158067
+ children: [
158068
+ {
158069
+ type: "element",
158070
+ tagName: "div",
158071
+ properties: {
158072
+ class: "share-icon"
158073
+ },
158074
+ children: []
158075
+ }
158076
+ ]
158077
+ });
158036
158078
  elements.push({
158037
158079
  type: "element",
158038
158080
  tagName: "dark-mode-toggle",
@@ -165340,10 +165382,178 @@ var rehypeQrCode_default = (ctx) => () => {
165340
165382
  ]
165341
165383
  }
165342
165384
  ];
165385
+ const qrcodeButton = qrcodeDialog[0];
165386
+ const qrcodeDialogElement = qrcodeDialog[1];
165343
165387
  if (originalChildren[0].type === "element" && originalChildren[0].tagName === "div") {
165344
- originalChildren[0].children.push(...qrcodeDialog);
165388
+ const floatingContainer = originalChildren[0].children.find(
165389
+ (child) => child.type === "element" && child.properties?.id === "floating-buttons-container"
165390
+ );
165391
+ if (floatingContainer && floatingContainer.type === "element") {
165392
+ floatingContainer.children.push(qrcodeButton);
165393
+ } else {
165394
+ originalChildren[0].children.push(qrcodeButton);
165395
+ }
165345
165396
  }
165346
- tree.children = originalChildren;
165397
+ tree.children = [...originalChildren, qrcodeDialogElement];
165398
+ };
165399
+ };
165400
+
165401
+ // src/rehypeShareDialog.ts
165402
+ var rehypeShareDialog_default = (ctx) => () => {
165403
+ return (tree, file) => {
165404
+ const originalChildren = tree.children;
165405
+ const headings = file.data.headings || [];
165406
+ if (!ctx.navigation.current?.href) {
165407
+ return;
165408
+ }
165409
+ const headingCheckboxes = headings.map((heading3) => ({
165410
+ type: "element",
165411
+ tagName: "label",
165412
+ properties: {
165413
+ class: `heading-item level-${heading3.level}`
165414
+ },
165415
+ children: [
165416
+ {
165417
+ type: "element",
165418
+ tagName: "input",
165419
+ properties: {
165420
+ type: "checkbox",
165421
+ value: heading3.anchor,
165422
+ "data-anchor": heading3.anchor,
165423
+ onchange: "hyperbook.shareUpdatePreview()"
165424
+ },
165425
+ children: []
165426
+ },
165427
+ {
165428
+ type: "text",
165429
+ value: ` ${heading3.label}`
165430
+ }
165431
+ ]
165432
+ }));
165433
+ const shareDialog = [
165434
+ {
165435
+ type: "element",
165436
+ tagName: "dialog",
165437
+ properties: {
165438
+ id: "share-dialog"
165439
+ },
165440
+ children: [
165441
+ {
165442
+ type: "element",
165443
+ tagName: "div",
165444
+ properties: {
165445
+ class: "container"
165446
+ },
165447
+ children: [
165448
+ {
165449
+ type: "element",
165450
+ tagName: "h2",
165451
+ properties: {
165452
+ class: "title"
165453
+ },
165454
+ children: [
165455
+ {
165456
+ type: "text",
165457
+ value: i18n.get("share-dialog-title")
165458
+ }
165459
+ ]
165460
+ },
165461
+ {
165462
+ type: "element",
165463
+ tagName: "label",
165464
+ properties: {
165465
+ class: "standalone-option"
165466
+ },
165467
+ children: [
165468
+ {
165469
+ type: "element",
165470
+ tagName: "input",
165471
+ properties: {
165472
+ type: "checkbox",
165473
+ id: "share-standalone-checkbox",
165474
+ onchange: "hyperbook.shareUpdatePreview()"
165475
+ },
165476
+ children: []
165477
+ },
165478
+ {
165479
+ type: "text",
165480
+ value: ` ${i18n.get("share-dialog-standalone")}`
165481
+ }
165482
+ ]
165483
+ },
165484
+ {
165485
+ type: "element",
165486
+ tagName: "h3",
165487
+ properties: {
165488
+ class: "sections-title"
165489
+ },
165490
+ children: [
165491
+ {
165492
+ type: "text",
165493
+ value: i18n.get("share-dialog-select-sections")
165494
+ }
165495
+ ]
165496
+ },
165497
+ {
165498
+ type: "element",
165499
+ tagName: "div",
165500
+ properties: {
165501
+ class: "sections-list"
165502
+ },
165503
+ children: headingCheckboxes
165504
+ },
165505
+ {
165506
+ type: "element",
165507
+ tagName: "div",
165508
+ properties: {
165509
+ class: "url-preview",
165510
+ id: "share-url-preview"
165511
+ },
165512
+ children: [
165513
+ {
165514
+ type: "text",
165515
+ value: ""
165516
+ }
165517
+ ]
165518
+ },
165519
+ {
165520
+ type: "element",
165521
+ tagName: "button",
165522
+ properties: {
165523
+ class: "copy-button",
165524
+ onclick: "hyperbook.shareCopyUrl()"
165525
+ },
165526
+ children: [
165527
+ {
165528
+ type: "text",
165529
+ value: i18n.get("share-dialog-copy-url")
165530
+ }
165531
+ ]
165532
+ }
165533
+ ]
165534
+ },
165535
+ {
165536
+ type: "element",
165537
+ tagName: "button",
165538
+ properties: {
165539
+ class: "close",
165540
+ onclick: "hyperbook.shareClose()"
165541
+ },
165542
+ children: [
165543
+ {
165544
+ type: "element",
165545
+ tagName: "div",
165546
+ properties: {
165547
+ class: "close-icon"
165548
+ },
165549
+ children: []
165550
+ }
165551
+ ]
165552
+ }
165553
+ ]
165554
+ }
165555
+ ];
165556
+ tree.children = [...originalChildren, ...shareDialog];
165347
165557
  };
165348
165558
  };
165349
165559
 
@@ -166451,7 +166661,8 @@ var remarkDirectiveMultievent_default = (ctx) => () => {
166451
166661
  registerDirective(file, name, ["multievent.js"], ["style.css"], []);
166452
166662
  data.hName = "div";
166453
166663
  data.hProperties = {
166454
- class: "directive-multievent multievent"
166664
+ class: "directive-multievent multievent",
166665
+ style: "visibility: hidden; opacity: 0;"
166455
166666
  };
166456
166667
  }
166457
166668
  });
@@ -173214,6 +173425,7 @@ var process2 = (md, ctx) => {
173214
173425
  rehypeUnwrapImages,
173215
173426
  rehypeTableOfContents_default(ctx),
173216
173427
  rehypeQrCode_default(ctx),
173428
+ rehypeShareDialog_default(ctx),
173217
173429
  rehypeKatex,
173218
173430
  rehypeDirectiveP5_default(ctx),
173219
173431
  [
@@ -173263,7 +173475,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
173263
173475
  /***/ ((module) => {
173264
173476
 
173265
173477
  "use strict";
173266
- module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.71.5","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
173478
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.72.0","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
173267
173479
 
173268
173480
  /***/ })
173269
173481
 
@@ -40,6 +40,12 @@
40
40
  "slideshow-next": "Weiter",
41
41
  "slideshow-jump-to": "Springe zu {{index}}",
42
42
  "toggle-bookmark": "Lesezeichen umschalten",
43
+ "shell-share": "Teilen",
44
+ "share-dialog-title": "Teilbare URL erstellen",
45
+ "share-dialog-standalone": "Standalone-Modus",
46
+ "share-dialog-select-sections": "Abschnitte auswählen",
47
+ "share-dialog-copy-url": "Teilbare URL kopieren",
48
+ "share-dialog-url-copied": "URL in Zwischenablage kopiert!",
43
49
  "webide-code-preview": "Code-Vorschau",
44
50
  "webide-html": "HTML",
45
51
  "webide-css": "CSS",
@@ -40,6 +40,12 @@
40
40
  "slideshow-next": "Next",
41
41
  "slideshow-jump-to": "Jump to {{index}}",
42
42
  "toggle-bookmark": "Toggle Bookmark",
43
+ "shell-share": "Share",
44
+ "share-dialog-title": "Create Shareable URL",
45
+ "share-dialog-standalone": "Standalone Mode",
46
+ "share-dialog-select-sections": "Select Sections",
47
+ "share-dialog-copy-url": "Copy Shareable URL",
48
+ "share-dialog-url-copied": "URL copied to clipboard!",
43
49
  "webide-code-preview": "Code Preview",
44
50
  "webide-html": "HTML",
45
51
  "webide-css": "CSS",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperbook",
3
- "version": "0.71.5",
3
+ "version": "0.72.0",
4
4
  "author": "Mike Barkmin",
5
5
  "homepage": "https://github.com/openpatch/hyperbook#readme",
6
6
  "license": "MIT",
@@ -57,8 +57,8 @@
57
57
  "update-check": "1.5.4",
58
58
  "ws": "^8.18.0",
59
59
  "create-hyperbook": "0.3.0",
60
+ "@hyperbook/markdown": "0.44.0",
60
61
  "@hyperbook/fs": "0.21.0",
61
- "@hyperbook/markdown": "0.43.5",
62
62
  "@hyperbook/types": "0.18.0"
63
63
  },
64
64
  "scripts": {