@hyperbook/markdown 0.25.0 → 0.25.2

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.
@@ -15,6 +15,7 @@ var hyperbook = (function () {
15
15
  });
16
16
  }
17
17
  collapsible.addEventListener("click", () => {
18
+ window.dispatchEvent(new Event("resize")); // geogebra new this in order resize the applet
18
19
  collapsible.classList.toggle("expanded");
19
20
  if (id) {
20
21
  store.collapsibles.get(id).then((result) => {
@@ -0,0 +1,37 @@
1
+ hyperbook.geogebra = (function () {
2
+ async function init(root) {
3
+ const els = root.getElementsByTagName("hyperbook-geogebra");
4
+ for (const el of els) {
5
+ const id = el.getAttribute("data-id");
6
+
7
+ const result = await store.geogebra.get(id);
8
+ if (result && result.state) {
9
+ el.setBase64(result.state);
10
+ }
11
+
12
+ el.registerUpdateListener(() => {
13
+ el.getBase64((b) => {
14
+ store.geogebra.put({ id, state: b });
15
+ });
16
+ });
17
+ }
18
+ }
19
+
20
+ const observer = new MutationObserver((mutations) => {
21
+ mutations.forEach((mutation) => {
22
+ mutation.addedNodes.forEach((node) => {
23
+ if (
24
+ node.nodeType === 1 &&
25
+ node.classList.contains("directive-geogebra")
26
+ ) {
27
+ // Element node
28
+ init(node);
29
+ }
30
+ });
31
+ });
32
+ });
33
+
34
+ observer.observe(document.body, { childList: true, subtree: true });
35
+
36
+ init(document);
37
+ })();
@@ -1,10 +1,3 @@
1
1
  .directive-geogebra {
2
- display: flex;
3
- justify-content: center;
4
- margin-bottom: 12px;
5
- }
6
-
7
- .directive-geogebra hyperbook-geogebra {
8
- overflow: hidden;
9
- border-radius: 8px;
2
+ margin: 12px auto;
10
3
  }
@@ -25,6 +25,7 @@ store.version(1).stores({
25
25
  excalidraw: `id,excalidrawElements,appState,files`,
26
26
  webide: `id,html,css,js`,
27
27
  h5p: `id,userData`,
28
+ geogebra: `id,state`,
28
29
  });
29
30
  var sqlIdeDB = new Dexie("SQL-IDE");
30
31
  sqlIdeDB.version(0.1).stores({
@@ -130,7 +131,7 @@ async function hyperbookImport() {
130
131
  alert(
131
132
  i18n.get("store-not-supported-file-version", {
132
133
  version: data.version,
133
- })
134
+ }),
134
135
  );
135
136
  return;
136
137
  }
package/dist/index.js CHANGED
@@ -73790,26 +73790,30 @@ var remarkDirectiveGeogebra_default = (ctx) => () => {
73790
73790
  if (isDirective(node3)) {
73791
73791
  if (node3.name !== name) return;
73792
73792
  const data = node3.data || (node3.data = {});
73793
+ const {
73794
+ src = "",
73795
+ id = hash(node3),
73796
+ height = 600,
73797
+ width = 800,
73798
+ showFullscreenButton = true,
73799
+ showResetIcon = true,
73800
+ ...props
73801
+ } = node3.attributes || {};
73793
73802
  registerDirective(
73794
73803
  file,
73795
73804
  name,
73796
73805
  [
73797
73806
  "https://www.geogebra.org/apps/deployggb.js",
73798
- "geogebra-web-component.js"
73807
+ "geogebra-web-component.js",
73808
+ "client.js"
73799
73809
  ],
73800
73810
  ["style.css"]
73801
73811
  );
73802
- const { src, ...props } = node3.attributes || {};
73803
73812
  data.hName = "div";
73804
73813
  data.hProperties = {
73805
- class: "directive-geogebra"
73814
+ class: "directive-geogebra",
73815
+ style: `max-height: ${height}px; max-width: ${width}px; aspect-ratio: ${width}/${height};`
73806
73816
  };
73807
- if (!src && !props.width) {
73808
- props.width = "800";
73809
- }
73810
- if (!src && !props.height) {
73811
- props.height = "600";
73812
- }
73813
73817
  const value = toText2(node3);
73814
73818
  data.hChildren = [
73815
73819
  {
@@ -73817,8 +73821,16 @@ var remarkDirectiveGeogebra_default = (ctx) => () => {
73817
73821
  tagName: "hyperbook-geogebra",
73818
73822
  properties: {
73819
73823
  ...props,
73824
+ height,
73825
+ width,
73820
73826
  borderRadius: 8,
73821
- material: src ? ctx.makeUrl(src, "public") : void 0
73827
+ material: src ? ctx.makeUrl(src, "public") : void 0,
73828
+ language: ctx.config.language || "en",
73829
+ "data-id": id,
73830
+ showFullscreenButton,
73831
+ scaleContainerClass: "directive-geogebra",
73832
+ allowUpscale: true,
73833
+ showResetIcon
73822
73834
  },
73823
73835
  children: [
73824
73836
  {