@doenet/doenetml-iframe 0.7.0-beta7 → 0.7.0-beta9
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/index.js +41 -16
- package/index.js.map +1 -1
- package/package.json +5 -2
package/index.js
CHANGED
|
@@ -23608,7 +23608,8 @@ const mathjaxConfig = {
|
|
|
23608
23608
|
amp: "&",
|
|
23609
23609
|
var: ["\\mathrm{#1}", 1],
|
|
23610
23610
|
csch: "\\operatorname{csch}",
|
|
23611
|
-
sech: "\\operatorname{sech}"
|
|
23611
|
+
sech: "\\operatorname{sech}",
|
|
23612
|
+
erf: "\\operatorname{erf}"
|
|
23612
23613
|
},
|
|
23613
23614
|
displayMath: [["\\[", "\\]"]]
|
|
23614
23615
|
},
|
|
@@ -23708,8 +23709,8 @@ function requireCssesc() {
|
|
|
23708
23709
|
return cssesc_1;
|
|
23709
23710
|
}
|
|
23710
23711
|
requireCssesc();
|
|
23711
|
-
const viewerIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", async () => {\n let pause100 = function() {\n return new Promise((resolve, _reject) => {\n setTimeout(resolve, 100);\n });\n };\n for (let i = 0; i < 10; i++) {\n if (typeof window.renderDoenetViewerToContainer === "function") {\n break;\n }\n await pause100();\n }\n if (typeof window.renderDoenetViewerToContainer !== "function") {\n return messageParentFromViewer({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n
|
|
23712
|
-
const editorIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", async () => {\n let pause100 = function() {\n return new Promise((resolve, _reject) => {\n setTimeout(resolve, 100);\n });\n };\n for (let i = 0; i < 10; i++) {\n if (typeof window.renderDoenetViewerToContainer === "function") {\n break;\n }\n await pause100();\n }\n if (typeof window.renderDoenetEditorToContainer !== "function") {\n return messageParentFromEditor({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n
|
|
23712
|
+
const viewerIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", async () => {\n let pause100 = function() {\n return new Promise((resolve, _reject) => {\n setTimeout(resolve, 100);\n });\n };\n for (let i = 0; i < 10; i++) {\n if (typeof window.renderDoenetViewerToContainer === "function") {\n break;\n }\n await pause100();\n }\n if (typeof window.renderDoenetViewerToContainer !== "function") {\n return messageParentFromViewer({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n });\n ComlinkViewer.expose(\n { renderViewerWithFunctionProps },\n ComlinkViewer.windowEndpoint(globalThis.parent)\n );\n function renderViewerWithFunctionProps(...args) {\n const augmentedDoenetViewerProps = { ...doenetViewerProps };\n augmentedDoenetViewerProps.externalVirtualKeyboardProvided = true;\n for (const propName of doenetViewerPropsSpecified) {\n if (!(propName in doenetViewerProps)) {\n const idx = args.indexOf(propName);\n if (idx !== -1) {\n augmentedDoenetViewerProps[propName] = args[idx + 1];\n }\n }\n }\n if (!doenetViewerPropsSpecified.includes("requestScrollTo")) {\n augmentedDoenetViewerProps.requestScrollTo = (offset) => {\n messageParentFromViewer({ type: "scrollTo", offset });\n };\n }\n window.renderDoenetViewerToContainer(\n document.getElementById("root"),\n void 0,\n augmentedDoenetViewerProps\n );\n }\n messageParentFromViewer({ iframeReady: true });\n window.addEventListener("message", (e) => {\n if (e.origin !== window.parent.location.origin) {\n return;\n }\n if (e.data.subject?.startsWith("SPLICE") && (!e.data.subject?.endsWith("response") || e.data.subject.endsWith("submitAllAnswers.response")) && !e.data.subject.endsWith("submitAllAnswers")) {\n window.parent.postMessage(e.data);\n } else if (e.data.subject === "requestAnswerResponses") {\n window.parent.postMessage(e.data);\n }\n });\n function messageParentFromViewer(data) {\n window.parent.postMessage(\n {\n origin: viewerId,\n data\n },\n window.parent.origin\n );\n }\n})();\n';
|
|
23713
|
+
const editorIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", async () => {\n let pause100 = function() {\n return new Promise((resolve, _reject) => {\n setTimeout(resolve, 100);\n });\n };\n for (let i = 0; i < 10; i++) {\n if (typeof window.renderDoenetViewerToContainer === "function") {\n break;\n }\n await pause100();\n }\n if (typeof window.renderDoenetEditorToContainer !== "function") {\n return messageParentFromEditor({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n });\n ComlinkEditor.expose(\n { renderEditorWithFunctionProps },\n ComlinkEditor.windowEndpoint(globalThis.parent)\n );\n function renderEditorWithFunctionProps(...args) {\n const augmentedDoenetEditorProps = { ...doenetEditorProps };\n augmentedDoenetEditorProps.externalVirtualKeyboardProvided = true;\n for (const propName of doenetEditorPropsSpecified) {\n if (!(propName in doenetEditorProps)) {\n const idx = args.indexOf(propName);\n if (idx !== -1) {\n augmentedDoenetEditorProps[propName] = args[idx + 1];\n }\n }\n }\n window.renderDoenetEditorToContainer(\n document.getElementById("root"),\n void 0,\n augmentedDoenetEditorProps\n );\n }\n messageParentFromEditor({ iframeReady: true });\n function messageParentFromEditor(data) {\n window.parent.postMessage(\n {\n origin: editorId,\n data\n },\n window.parent.origin\n );\n }\n})();\n';
|
|
23713
23714
|
function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneUrl, cssUrl) {
|
|
23714
23715
|
const doenetViewerPropsSpecified = Object.keys(doenetViewerProps);
|
|
23715
23716
|
return `
|
|
@@ -46763,7 +46764,7 @@ function ExternalVirtualKeyboard() {
|
|
|
46763
46764
|
}
|
|
46764
46765
|
);
|
|
46765
46766
|
}
|
|
46766
|
-
const version = "0.7.0-
|
|
46767
|
+
const version = "0.7.0-beta9";
|
|
46767
46768
|
const latestDoenetmlVersion = version;
|
|
46768
46769
|
function DoenetViewer({
|
|
46769
46770
|
doenetML,
|
|
@@ -46823,18 +46824,30 @@ function DoenetViewer({
|
|
|
46823
46824
|
}
|
|
46824
46825
|
if (data.error) {
|
|
46825
46826
|
return setInErrorState(data.error);
|
|
46827
|
+
} else if (data.iframeReady) {
|
|
46828
|
+
if (ref.current) {
|
|
46829
|
+
const viewerIframe = wrap$2(
|
|
46830
|
+
windowEndpoint(ref.current.contentWindow)
|
|
46831
|
+
);
|
|
46832
|
+
const proxiedFunctions = [];
|
|
46833
|
+
for (const [key, prop] of Object.entries(
|
|
46834
|
+
doenetViewerProps
|
|
46835
|
+
)) {
|
|
46836
|
+
if (typeof prop === "function") {
|
|
46837
|
+
proxiedFunctions.push(key);
|
|
46838
|
+
proxiedFunctions.push(proxy(prop));
|
|
46839
|
+
}
|
|
46840
|
+
}
|
|
46841
|
+
viewerIframe?.renderViewerWithFunctionProps(
|
|
46842
|
+
...proxiedFunctions
|
|
46843
|
+
);
|
|
46844
|
+
}
|
|
46826
46845
|
}
|
|
46827
46846
|
};
|
|
46828
46847
|
if (ref.current) {
|
|
46829
46848
|
window.addEventListener("message", listener);
|
|
46830
46849
|
}
|
|
46831
46850
|
const clearResize = watchForResize(ref, () => height, setHeight);
|
|
46832
|
-
if (ref.current) {
|
|
46833
|
-
expose(
|
|
46834
|
-
doenetViewerProps,
|
|
46835
|
-
windowEndpoint(ref.current.contentWindow)
|
|
46836
|
-
);
|
|
46837
|
-
}
|
|
46838
46851
|
return () => {
|
|
46839
46852
|
window.removeEventListener("message", listener);
|
|
46840
46853
|
clearResize();
|
|
@@ -46946,17 +46959,29 @@ function DoenetEditor({
|
|
|
46946
46959
|
const data = event.data.data;
|
|
46947
46960
|
if (data.error) {
|
|
46948
46961
|
return setInErrorState(data.error);
|
|
46962
|
+
} else if (data.iframeReady) {
|
|
46963
|
+
if (ref.current) {
|
|
46964
|
+
const editorIframe = wrap$2(
|
|
46965
|
+
windowEndpoint(ref.current.contentWindow)
|
|
46966
|
+
);
|
|
46967
|
+
const proxiedFunctions = [];
|
|
46968
|
+
for (const [key, prop] of Object.entries(
|
|
46969
|
+
doenetEditorProps
|
|
46970
|
+
)) {
|
|
46971
|
+
if (typeof prop === "function") {
|
|
46972
|
+
proxiedFunctions.push(key);
|
|
46973
|
+
proxiedFunctions.push(proxy(prop));
|
|
46974
|
+
}
|
|
46975
|
+
}
|
|
46976
|
+
editorIframe?.renderEditorWithFunctionProps(
|
|
46977
|
+
...proxiedFunctions
|
|
46978
|
+
);
|
|
46979
|
+
}
|
|
46949
46980
|
}
|
|
46950
46981
|
};
|
|
46951
46982
|
if (ref.current) {
|
|
46952
46983
|
window.addEventListener("message", listener);
|
|
46953
46984
|
}
|
|
46954
|
-
if (ref.current) {
|
|
46955
|
-
expose(
|
|
46956
|
-
doenetEditorProps,
|
|
46957
|
-
windowEndpoint(ref.current.contentWindow)
|
|
46958
|
-
);
|
|
46959
|
-
}
|
|
46960
46985
|
return () => {
|
|
46961
46986
|
window.removeEventListener("message", listener);
|
|
46962
46987
|
};
|