hyperbook 0.48.4 → 0.48.6

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.
@@ -4,7 +4,7 @@ hyperbook.p5 = (function () {
4
4
  codeInput.templates.prism(window.Prism, [
5
5
  new codeInput.plugins.AutoCloseBrackets(),
6
6
  new codeInput.plugins.Indent(true, 2),
7
- ])
7
+ ]),
8
8
  );
9
9
 
10
10
  const elems = document.getElementsByClassName("directive-p5");
@@ -32,6 +32,13 @@ hyperbook.p5 = (function () {
32
32
  const resetEl = elem.getElementsByClassName("reset")[0];
33
33
  const downloadEl = elem.getElementsByClassName("download")[0];
34
34
 
35
+ if (frame) {
36
+ frame.srcdoc = frame.srcdoc.replaceAll(
37
+ "###ORIGIN###",
38
+ window.location.origin,
39
+ );
40
+ }
41
+
35
42
  copyEl?.addEventListener("click", async () => {
36
43
  try {
37
44
  await navigator.clipboard.writeText(editor.value);
@@ -61,6 +68,7 @@ hyperbook.p5 = (function () {
61
68
  const code = result.sketch;
62
69
  frame.srcdoc = template
63
70
  .replace("###SLOT###", wrapSketch(code))
71
+ .replaceAll("###ORIGIN###", window.location.origin)
64
72
  .replace(/\u00A0/g, " ");
65
73
  }
66
74
 
@@ -71,7 +79,9 @@ hyperbook.p5 = (function () {
71
79
 
72
80
  update?.addEventListener("click", () => {
73
81
  const code = editor.value;
74
- frame.srcdoc = template.replace("###SLOT###", wrapSketch(code));
82
+ frame.srcdoc = template
83
+ .replace("###SLOT###", wrapSketch(code))
84
+ .replaceAll("###ORIGIN###", window.location.origin);
75
85
  });
76
86
  });
77
87
  }