@hyperbook/markdown 0.44.0 → 0.45.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
@@ -61265,6 +61265,7 @@ function remarkDirectiveTabs_default(ctx) {
61265
61265
  if (!tabsId) {
61266
61266
  tabsId = hash(node3);
61267
61267
  }
61268
+ const instanceId = hash(node3);
61268
61269
  registerDirective(
61269
61270
  file,
61270
61271
  "tabs",
@@ -61291,8 +61292,23 @@ function remarkDirectiveTabs_default(ctx) {
61291
61292
  }
61292
61293
  tabTitleElements.push({
61293
61294
  type: "element",
61294
- tagName: "button",
61295
+ tagName: "input",
61295
61296
  properties: {
61297
+ type: "radio",
61298
+ name: `tabs-${instanceId}`,
61299
+ id: `tab-${instanceId}-${tabId}`,
61300
+ "data-tab-id": tabId,
61301
+ "data-tabs-id": tabsId,
61302
+ class: "tab-input",
61303
+ checked: first
61304
+ },
61305
+ children: []
61306
+ });
61307
+ tabTitleElements.push({
61308
+ type: "element",
61309
+ tagName: "label",
61310
+ properties: {
61311
+ for: `tab-${instanceId}-${tabId}`,
61296
61312
  "data-tab-id": tabId,
61297
61313
  "data-tabs-id": tabsId,
61298
61314
  class: "tab" + (first ? " active" : "")
@@ -61312,7 +61328,15 @@ function remarkDirectiveTabs_default(ctx) {
61312
61328
  });
61313
61329
  first = false;
61314
61330
  }
61331
+ const radioInputs = [];
61332
+ const labelElements = [];
61333
+ for (let i = 0; i < tabTitleElements.length; i += 2) {
61334
+ radioInputs.push(tabTitleElements[i]);
61335
+ labelElements.push(tabTitleElements[i + 1]);
61336
+ }
61315
61337
  data.hChildren = [
61338
+ ...radioInputs,
61339
+ // Radio inputs as direct children
61316
61340
  {
61317
61341
  type: "element",
61318
61342
  tagName: "div",
@@ -61320,7 +61344,8 @@ function remarkDirectiveTabs_default(ctx) {
61320
61344
  class: "tabs",
61321
61345
  "data-tabs-id": tabsId
61322
61346
  },
61323
- children: tabTitleElements
61347
+ children: labelElements
61348
+ // Only labels in tabs div
61324
61349
  },
61325
61350
  ...tabContentElements
61326
61351
  ];
@@ -62425,11 +62450,13 @@ body::-webkit-scrollbar {
62425
62450
  font-family: hyperbook-heading;
62426
62451
  src: url(${makeUrl(parseFont(font)[0], "public")});
62427
62452
  size-adjust: ${parseFont(font)[1]};
62453
+ font-display: swap;
62428
62454
  }
62429
62455
  @font-face {
62430
62456
  font-family: hyperbook-body;
62431
62457
  src: url(${makeUrl(parseFont(font)[0], "public")});
62432
62458
  size-adjust: ${parseFont(font)[1]};
62459
+ font-display: swap;
62433
62460
  }
62434
62461
  `;
62435
62462
  }
@@ -62439,6 +62466,7 @@ body::-webkit-scrollbar {
62439
62466
  font-family: hyperbook-body;
62440
62467
  src: url(${makeUrl(parseFont(fonts.body)[0], "public")});
62441
62468
  size-adjust: ${parseFont(fonts.body)[1]};
62469
+ font-display: swap;
62442
62470
  }
62443
62471
  `;
62444
62472
  }
@@ -62448,6 +62476,7 @@ body::-webkit-scrollbar {
62448
62476
  font-family: hyperbook-heading;
62449
62477
  src: url(${makeUrl(parseFont(fonts.heading)[0], "public")});
62450
62478
  size-adjust: ${parseFont(fonts.heading)[1]};
62479
+ font-display: swap;
62451
62480
  }
62452
62481
  `;
62453
62482
  }
@@ -62457,6 +62486,7 @@ body::-webkit-scrollbar {
62457
62486
  font-family: hyperbook-code;
62458
62487
  src: url(${makeUrl(parseFont(fonts.code)[0], "public")});
62459
62488
  size-adjust: ${parseFont(fonts.code)[1]};
62489
+ font-display: swap;
62460
62490
  }
62461
62491
  `;
62462
62492
  }
@@ -62504,7 +62534,8 @@ var rehypeHtmlStructure_default = (ctx) => () => {
62504
62534
  type: "element",
62505
62535
  tagName: "html",
62506
62536
  properties: {
62507
- lang: config2.language || "es"
62537
+ lang: config2.language || "es",
62538
+ class: "no-js"
62508
62539
  },
62509
62540
  children: [
62510
62541
  {
@@ -62644,6 +62675,19 @@ var rehypeHtmlStructure_default = (ctx) => () => {
62644
62675
  }
62645
62676
  ]
62646
62677
  },
62678
+ {
62679
+ type: "element",
62680
+ tagName: "script",
62681
+ properties: {},
62682
+ children: [
62683
+ {
62684
+ type: "raw",
62685
+ value: `
62686
+ // Remove no-js class as soon as JavaScript is available
62687
+ document.documentElement.classList.remove('no-js');`
62688
+ }
62689
+ ]
62690
+ },
62647
62691
  {
62648
62692
  type: "element",
62649
62693
  tagName: "script",
@@ -62668,7 +62712,8 @@ var rehypeHtmlStructure_default = (ctx) => () => {
62668
62712
  type: "element",
62669
62713
  tagName: "script",
62670
62714
  properties: {
62671
- src: makeUrl(["i18n.js"], "assets")
62715
+ src: makeUrl(["i18n.js"], "assets"),
62716
+ defer: true
62672
62717
  },
62673
62718
  children: []
62674
62719
  },
@@ -62676,7 +62721,8 @@ var rehypeHtmlStructure_default = (ctx) => () => {
62676
62721
  type: "element",
62677
62722
  tagName: "script",
62678
62723
  properties: {
62679
- src: makeUrl(["dexie.min.js"], "assets")
62724
+ src: makeUrl(["dexie.min.js"], "assets"),
62725
+ defer: true
62680
62726
  },
62681
62727
  children: []
62682
62728
  },
@@ -62684,7 +62730,8 @@ var rehypeHtmlStructure_default = (ctx) => () => {
62684
62730
  type: "element",
62685
62731
  tagName: "script",
62686
62732
  properties: {
62687
- src: makeUrl(["dexie-export-import.js"], "assets")
62733
+ src: makeUrl(["dexie-export-import.js"], "assets"),
62734
+ defer: true
62688
62735
  },
62689
62736
  children: []
62690
62737
  },
@@ -62692,7 +62739,8 @@ var rehypeHtmlStructure_default = (ctx) => () => {
62692
62739
  type: "element",
62693
62740
  tagName: "script",
62694
62741
  properties: {
62695
- src: makeUrl(["store.js"], "assets")
62742
+ src: makeUrl(["store.js"], "assets"),
62743
+ defer: true
62696
62744
  },
62697
62745
  children: []
62698
62746
  },
@@ -62713,7 +62761,8 @@ window.Prism.manual = true;`
62713
62761
  type: "element",
62714
62762
  tagName: "script",
62715
62763
  properties: {
62716
- src: makeUrl(["prism", "prism.js"], "assets")
62764
+ src: makeUrl(["prism", "prism.js"], "assets"),
62765
+ defer: true
62717
62766
  },
62718
62767
  children: []
62719
62768
  },
@@ -62969,69 +63018,7 @@ var makeNavigationPageElement = (ctx, page) => {
62969
63018
  };
62970
63019
  var makeNavigationSectionElement = (ctx, section) => {
62971
63020
  const { virtual, isEmpty, href, name, pages, sections, expanded } = section;
62972
- const children = [];
62973
63021
  let isExpanded = ctx.navigation.current?.href?.startsWith(href || "") || expanded;
62974
- if (!virtual) {
62975
- if (isEmpty) {
62976
- children.push({
62977
- type: "element",
62978
- tagName: "div",
62979
- properties: {
62980
- class: [
62981
- "collapsible",
62982
- "name",
62983
- "empty",
62984
- ctx.navigation.current?.href === href ? "active" : "",
62985
- isExpanded ? "expanded" : ""
62986
- ].join(" ")
62987
- },
62988
- children: [
62989
- {
62990
- type: "element",
62991
- tagName: "span",
62992
- properties: {
62993
- class: "label"
62994
- },
62995
- children: [
62996
- {
62997
- type: "text",
62998
- value: name
62999
- }
63000
- ]
63001
- }
63002
- ]
63003
- });
63004
- } else {
63005
- children.push({
63006
- type: "element",
63007
- tagName: "div",
63008
- properties: {
63009
- class: [
63010
- "collapsible",
63011
- "name",
63012
- ctx.navigation.current?.href === href ? "active" : "",
63013
- isExpanded ? "expanded" : ""
63014
- ].join(" ")
63015
- },
63016
- children: [
63017
- {
63018
- type: "element",
63019
- tagName: "a",
63020
- properties: {
63021
- href: ctx.makeUrl(href || "", "book"),
63022
- class: "label"
63023
- },
63024
- children: [
63025
- {
63026
- type: "text",
63027
- value: name
63028
- }
63029
- ]
63030
- }
63031
- ]
63032
- });
63033
- }
63034
- }
63035
63022
  const pagesElements = pages.filter((page) => !page.hide).map((page) => makeNavigationPageElement(ctx, page));
63036
63023
  const linksElements = [];
63037
63024
  if (pagesElements.length > 0) {
@@ -63046,22 +63033,86 @@ var makeNavigationSectionElement = (ctx, section) => {
63046
63033
  }
63047
63034
  const sectionElements = sections.filter((s3) => !s3.hide).map((s3) => makeNavigationSectionElement(ctx, s3));
63048
63035
  linksElements.push(...sectionElements);
63049
- children.push({
63050
- type: "element",
63051
- tagName: "div",
63052
- properties: {
63053
- class: virtual ? "links" : "collapsible-content links"
63054
- },
63055
- children: linksElements
63056
- });
63036
+ if (virtual) {
63037
+ return {
63038
+ type: "element",
63039
+ tagName: "div",
63040
+ properties: {
63041
+ class: "virtual-section"
63042
+ },
63043
+ children: [
63044
+ {
63045
+ type: "element",
63046
+ tagName: "div",
63047
+ properties: {
63048
+ class: "links"
63049
+ },
63050
+ children: linksElements
63051
+ }
63052
+ ]
63053
+ };
63054
+ }
63055
+ const summaryChildren = [];
63056
+ if (isEmpty) {
63057
+ summaryChildren.push({
63058
+ type: "element",
63059
+ tagName: "span",
63060
+ properties: {
63061
+ class: "label"
63062
+ },
63063
+ children: [
63064
+ {
63065
+ type: "text",
63066
+ value: name
63067
+ }
63068
+ ]
63069
+ });
63070
+ } else {
63071
+ summaryChildren.push({
63072
+ type: "element",
63073
+ tagName: "a",
63074
+ properties: {
63075
+ href: ctx.makeUrl(href || "", "book"),
63076
+ class: "label"
63077
+ },
63078
+ children: [
63079
+ {
63080
+ type: "text",
63081
+ value: name
63082
+ }
63083
+ ]
63084
+ });
63085
+ }
63057
63086
  return {
63058
63087
  type: "element",
63059
- tagName: "div",
63088
+ tagName: "details",
63060
63089
  properties: {
63061
63090
  "data-id": `_nav:${href}`,
63062
- class: virtual ? "virtual-section" : "section"
63091
+ class: [
63092
+ "section",
63093
+ ctx.navigation.current?.href === href ? "active" : "",
63094
+ isEmpty ? "empty" : ""
63095
+ ].join(" "),
63096
+ open: isExpanded
63063
63097
  },
63064
- children
63098
+ children: [
63099
+ {
63100
+ type: "element",
63101
+ tagName: "summary",
63102
+ properties: {
63103
+ class: "name"
63104
+ },
63105
+ children: summaryChildren
63106
+ },
63107
+ {
63108
+ type: "element",
63109
+ tagName: "div",
63110
+ properties: {
63111
+ class: "links"
63112
+ },
63113
+ children: linksElements
63114
+ }
63115
+ ]
63065
63116
  };
63066
63117
  };
63067
63118
  var makeNavigationElements = (ctx) => {
@@ -63373,7 +63424,8 @@ var makeHeaderElements = (ctx) => {
63373
63424
  tagName: "img",
63374
63425
  properties: {
63375
63426
  alt: "logo",
63376
- src: ctx.makeUrl(ctx.config.logo, "public")
63427
+ src: ctx.makeUrl(ctx.config.logo, "public"),
63428
+ height: "40"
63377
63429
  },
63378
63430
  children: []
63379
63431
  }
@@ -64327,10 +64379,8 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64327
64379
  return [
64328
64380
  {
64329
64381
  type: "element",
64330
- tagName: "button",
64331
- properties: {
64332
- class: "collapsible"
64333
- },
64382
+ tagName: "summary",
64383
+ properties: {},
64334
64384
  children: [
64335
64385
  {
64336
64386
  type: "text",
@@ -64342,7 +64392,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64342
64392
  type: "element",
64343
64393
  tagName: "div",
64344
64394
  properties: {
64345
- class: "collapsible-content"
64395
+ class: "content"
64346
64396
  },
64347
64397
  children: element5.children.flatMap(transformCollapsible)
64348
64398
  }
@@ -64365,7 +64415,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64365
64415
  expectContainerDirective(node3, file, name);
64366
64416
  registerDirective(file, name, [], ["style.css"], []);
64367
64417
  node3.attributes = {};
64368
- data.hName = "div";
64418
+ data.hName = "details";
64369
64419
  data.hProperties = {
64370
64420
  class: "directive-collapsible",
64371
64421
  "data-id": id
@@ -64377,10 +64427,8 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64377
64427
  data.hChildren = [
64378
64428
  {
64379
64429
  type: "element",
64380
- tagName: "button",
64381
- properties: {
64382
- class: "collapsible"
64383
- },
64430
+ tagName: "summary",
64431
+ properties: {},
64384
64432
  children: [
64385
64433
  {
64386
64434
  type: "text",
@@ -64392,7 +64440,7 @@ var remarkDirectiveCollapsible_default = (ctx) => () => {
64392
64440
  type: "element",
64393
64441
  tagName: "div",
64394
64442
  properties: {
64395
- class: "collapsible-content"
64443
+ class: "content"
64396
64444
  },
64397
64445
  children: collapsibleContent
64398
64446
  }