@hyperbook/markdown 0.43.4 → 0.44.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/index.js CHANGED
@@ -61475,6 +61475,12 @@ var en_default = {
61475
61475
  "slideshow-next": "Next",
61476
61476
  "slideshow-jump-to": "Jump to {{index}}",
61477
61477
  "toggle-bookmark": "Toggle Bookmark",
61478
+ "shell-share": "Share",
61479
+ "share-dialog-title": "Create Shareable URL",
61480
+ "share-dialog-standalone": "Standalone Mode",
61481
+ "share-dialog-select-sections": "Select Sections",
61482
+ "share-dialog-copy-url": "Copy Shareable URL",
61483
+ "share-dialog-url-copied": "URL copied to clipboard!",
61478
61484
  "webide-code-preview": "Code Preview",
61479
61485
  "webide-html": "HTML",
61480
61486
  "webide-css": "CSS",
@@ -61528,6 +61534,12 @@ var de_default = {
61528
61534
  "slideshow-next": "Weiter",
61529
61535
  "slideshow-jump-to": "Springe zu {{index}}",
61530
61536
  "toggle-bookmark": "Lesezeichen umschalten",
61537
+ "shell-share": "Teilen",
61538
+ "share-dialog-title": "Teilbare URL erstellen",
61539
+ "share-dialog-standalone": "Standalone-Modus",
61540
+ "share-dialog-select-sections": "Abschnitte ausw\xE4hlen",
61541
+ "share-dialog-copy-url": "Teilbare URL kopieren",
61542
+ "share-dialog-url-copied": "URL in Zwischenablage kopiert!",
61531
61543
  "webide-code-preview": "Code-Vorschau",
61532
61544
  "webide-html": "HTML",
61533
61545
  "webide-css": "CSS",
@@ -61690,105 +61702,115 @@ var rehypeTableOfContents_default = (ctx) => () => {
61690
61702
  return (tree, file) => {
61691
61703
  const headings = file.data.headings || [];
61692
61704
  const originalChildren = tree.children;
61693
- const tocSidebar = [
61694
- {
61695
- type: "element",
61696
- tagName: "button",
61697
- properties: {
61698
- id: "toc-toggle",
61699
- onclick: "hyperbook.tocToggle()",
61700
- title: i18n.get("table-of-contents")
61705
+ const tocButton = {
61706
+ type: "element",
61707
+ tagName: "button",
61708
+ properties: {
61709
+ id: "toc-toggle",
61710
+ onclick: "hyperbook.tocToggle()",
61711
+ title: i18n.get("table-of-contents")
61712
+ },
61713
+ children: [
61714
+ {
61715
+ type: "element",
61716
+ tagName: "div",
61717
+ properties: {
61718
+ class: "bar1"
61719
+ },
61720
+ children: []
61701
61721
  },
61702
- children: [
61703
- {
61704
- type: "element",
61705
- tagName: "div",
61706
- properties: {
61707
- class: "bar1"
61708
- },
61709
- children: []
61722
+ {
61723
+ type: "element",
61724
+ tagName: "div",
61725
+ properties: {
61726
+ class: "bar2"
61710
61727
  },
61711
- {
61712
- type: "element",
61713
- tagName: "div",
61714
- properties: {
61715
- class: "bar2"
61716
- },
61717
- children: []
61728
+ children: []
61729
+ },
61730
+ {
61731
+ type: "element",
61732
+ tagName: "div",
61733
+ properties: {
61734
+ class: "bar3"
61718
61735
  },
61719
- {
61720
- type: "element",
61721
- tagName: "div",
61722
- properties: {
61723
- class: "bar3"
61724
- },
61725
- children: []
61736
+ children: []
61737
+ },
61738
+ {
61739
+ type: "element",
61740
+ tagName: "div",
61741
+ properties: {
61742
+ class: "bar4"
61726
61743
  },
61727
- {
61728
- type: "element",
61729
- tagName: "div",
61730
- properties: {
61731
- class: "bar4"
61732
- },
61733
- children: []
61734
- }
61735
- ]
61744
+ children: []
61745
+ }
61746
+ ]
61747
+ };
61748
+ const tocDrawer = {
61749
+ type: "element",
61750
+ tagName: "side-drawer",
61751
+ properties: {
61752
+ id: "toc-drawer",
61753
+ right: true
61736
61754
  },
61755
+ children: [
61756
+ {
61757
+ type: "element",
61758
+ tagName: "div",
61759
+ properties: {
61760
+ class: "toc-drawer-content"
61761
+ },
61762
+ children: [
61763
+ {
61764
+ type: "element",
61765
+ tagName: "nav",
61766
+ properties: {
61767
+ class: "toc"
61768
+ },
61769
+ children: [
61770
+ {
61771
+ type: "element",
61772
+ tagName: "ul",
61773
+ properties: {},
61774
+ children: headings.map((heading3) => ({
61775
+ type: "element",
61776
+ tagName: "li",
61777
+ properties: {
61778
+ class: `level-${heading3.level}`
61779
+ },
61780
+ children: [
61781
+ {
61782
+ type: "element",
61783
+ tagName: "a",
61784
+ properties: {
61785
+ href: `#${heading3.anchor}`
61786
+ },
61787
+ children: [
61788
+ {
61789
+ type: "text",
61790
+ value: heading3.label
61791
+ }
61792
+ ]
61793
+ }
61794
+ ]
61795
+ }))
61796
+ }
61797
+ ]
61798
+ }
61799
+ ]
61800
+ }
61801
+ ]
61802
+ };
61803
+ const tocSidebar = [
61737
61804
  {
61738
61805
  type: "element",
61739
- tagName: "side-drawer",
61806
+ tagName: "div",
61740
61807
  properties: {
61741
- id: "toc-drawer",
61742
- right: true
61808
+ class: "floating-buttons-container",
61809
+ id: "floating-buttons-container"
61743
61810
  },
61744
- children: [
61745
- {
61746
- type: "element",
61747
- tagName: "div",
61748
- properties: {
61749
- class: "toc-drawer-content"
61750
- },
61751
- children: [
61752
- {
61753
- type: "element",
61754
- tagName: "nav",
61755
- properties: {
61756
- class: "toc"
61757
- },
61758
- children: [
61759
- {
61760
- type: "element",
61761
- tagName: "ul",
61762
- properties: {},
61763
- children: headings.map((heading3) => ({
61764
- type: "element",
61765
- tagName: "li",
61766
- properties: {
61767
- class: `level-${heading3.level}`
61768
- },
61769
- children: [
61770
- {
61771
- type: "element",
61772
- tagName: "a",
61773
- properties: {
61774
- href: `#${heading3.anchor}`
61775
- },
61776
- children: [
61777
- {
61778
- type: "text",
61779
- value: heading3.label
61780
- }
61781
- ]
61782
- }
61783
- ]
61784
- }))
61785
- }
61786
- ]
61787
- }
61788
- ]
61789
- }
61790
- ]
61791
- }
61811
+ children: [tocButton]
61812
+ },
61813
+ tocDrawer
61792
61814
  ];
61793
61815
  tree.children = [
61794
61816
  {
@@ -63591,6 +63613,26 @@ var makeHeaderElements = (ctx) => {
63591
63613
  ]
63592
63614
  });
63593
63615
  }
63616
+ elements.push({
63617
+ type: "element",
63618
+ tagName: "button",
63619
+ properties: {
63620
+ id: "share-button",
63621
+ class: "icon-button",
63622
+ title: i18n.get("shell-share"),
63623
+ onclick: "hyperbook.shareOpen()"
63624
+ },
63625
+ children: [
63626
+ {
63627
+ type: "element",
63628
+ tagName: "div",
63629
+ properties: {
63630
+ class: "share-icon"
63631
+ },
63632
+ children: []
63633
+ }
63634
+ ]
63635
+ });
63594
63636
  elements.push({
63595
63637
  type: "element",
63596
63638
  tagName: "dark-mode-toggle",
@@ -70898,10 +70940,178 @@ var rehypeQrCode_default = (ctx) => () => {
70898
70940
  ]
70899
70941
  }
70900
70942
  ];
70943
+ const qrcodeButton = qrcodeDialog[0];
70944
+ const qrcodeDialogElement = qrcodeDialog[1];
70901
70945
  if (originalChildren[0].type === "element" && originalChildren[0].tagName === "div") {
70902
- originalChildren[0].children.push(...qrcodeDialog);
70946
+ const floatingContainer = originalChildren[0].children.find(
70947
+ (child) => child.type === "element" && child.properties?.id === "floating-buttons-container"
70948
+ );
70949
+ if (floatingContainer && floatingContainer.type === "element") {
70950
+ floatingContainer.children.push(qrcodeButton);
70951
+ } else {
70952
+ originalChildren[0].children.push(qrcodeButton);
70953
+ }
70903
70954
  }
70904
- tree.children = originalChildren;
70955
+ tree.children = [...originalChildren, qrcodeDialogElement];
70956
+ };
70957
+ };
70958
+
70959
+ // src/rehypeShareDialog.ts
70960
+ var rehypeShareDialog_default = (ctx) => () => {
70961
+ return (tree, file) => {
70962
+ const originalChildren = tree.children;
70963
+ const headings = file.data.headings || [];
70964
+ if (!ctx.navigation.current?.href) {
70965
+ return;
70966
+ }
70967
+ const headingCheckboxes = headings.map((heading3) => ({
70968
+ type: "element",
70969
+ tagName: "label",
70970
+ properties: {
70971
+ class: `heading-item level-${heading3.level}`
70972
+ },
70973
+ children: [
70974
+ {
70975
+ type: "element",
70976
+ tagName: "input",
70977
+ properties: {
70978
+ type: "checkbox",
70979
+ value: heading3.anchor,
70980
+ "data-anchor": heading3.anchor,
70981
+ onchange: "hyperbook.shareUpdatePreview()"
70982
+ },
70983
+ children: []
70984
+ },
70985
+ {
70986
+ type: "text",
70987
+ value: ` ${heading3.label}`
70988
+ }
70989
+ ]
70990
+ }));
70991
+ const shareDialog = [
70992
+ {
70993
+ type: "element",
70994
+ tagName: "dialog",
70995
+ properties: {
70996
+ id: "share-dialog"
70997
+ },
70998
+ children: [
70999
+ {
71000
+ type: "element",
71001
+ tagName: "div",
71002
+ properties: {
71003
+ class: "container"
71004
+ },
71005
+ children: [
71006
+ {
71007
+ type: "element",
71008
+ tagName: "h2",
71009
+ properties: {
71010
+ class: "title"
71011
+ },
71012
+ children: [
71013
+ {
71014
+ type: "text",
71015
+ value: i18n.get("share-dialog-title")
71016
+ }
71017
+ ]
71018
+ },
71019
+ {
71020
+ type: "element",
71021
+ tagName: "label",
71022
+ properties: {
71023
+ class: "standalone-option"
71024
+ },
71025
+ children: [
71026
+ {
71027
+ type: "element",
71028
+ tagName: "input",
71029
+ properties: {
71030
+ type: "checkbox",
71031
+ id: "share-standalone-checkbox",
71032
+ onchange: "hyperbook.shareUpdatePreview()"
71033
+ },
71034
+ children: []
71035
+ },
71036
+ {
71037
+ type: "text",
71038
+ value: ` ${i18n.get("share-dialog-standalone")}`
71039
+ }
71040
+ ]
71041
+ },
71042
+ {
71043
+ type: "element",
71044
+ tagName: "h3",
71045
+ properties: {
71046
+ class: "sections-title"
71047
+ },
71048
+ children: [
71049
+ {
71050
+ type: "text",
71051
+ value: i18n.get("share-dialog-select-sections")
71052
+ }
71053
+ ]
71054
+ },
71055
+ {
71056
+ type: "element",
71057
+ tagName: "div",
71058
+ properties: {
71059
+ class: "sections-list"
71060
+ },
71061
+ children: headingCheckboxes
71062
+ },
71063
+ {
71064
+ type: "element",
71065
+ tagName: "div",
71066
+ properties: {
71067
+ class: "url-preview",
71068
+ id: "share-url-preview"
71069
+ },
71070
+ children: [
71071
+ {
71072
+ type: "text",
71073
+ value: ""
71074
+ }
71075
+ ]
71076
+ },
71077
+ {
71078
+ type: "element",
71079
+ tagName: "button",
71080
+ properties: {
71081
+ class: "copy-button",
71082
+ onclick: "hyperbook.shareCopyUrl()"
71083
+ },
71084
+ children: [
71085
+ {
71086
+ type: "text",
71087
+ value: i18n.get("share-dialog-copy-url")
71088
+ }
71089
+ ]
71090
+ }
71091
+ ]
71092
+ },
71093
+ {
71094
+ type: "element",
71095
+ tagName: "button",
71096
+ properties: {
71097
+ class: "close",
71098
+ onclick: "hyperbook.shareClose()"
71099
+ },
71100
+ children: [
71101
+ {
71102
+ type: "element",
71103
+ tagName: "div",
71104
+ properties: {
71105
+ class: "close-icon"
71106
+ },
71107
+ children: []
71108
+ }
71109
+ ]
71110
+ }
71111
+ ]
71112
+ }
71113
+ ];
71114
+ tree.children = [...originalChildren, ...shareDialog];
70905
71115
  };
70906
71116
  };
70907
71117
 
@@ -72009,7 +72219,8 @@ var remarkDirectiveMultievent_default = (ctx) => () => {
72009
72219
  registerDirective(file, name, ["multievent.js"], ["style.css"], []);
72010
72220
  data.hName = "div";
72011
72221
  data.hProperties = {
72012
- class: "directive-multievent multievent"
72222
+ class: "directive-multievent multievent",
72223
+ style: "visibility: hidden; opacity: 0;"
72013
72224
  };
72014
72225
  }
72015
72226
  });
@@ -78772,6 +78983,7 @@ var process2 = (md, ctx) => {
78772
78983
  rehypeUnwrapImages,
78773
78984
  rehypeTableOfContents_default(ctx),
78774
78985
  rehypeQrCode_default(ctx),
78986
+ rehypeShareDialog_default(ctx),
78775
78987
  rehypeKatex,
78776
78988
  rehypeDirectiveP5_default(ctx),
78777
78989
  [