hyperbook 0.50.0 → 0.50.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
  }