@doenet/doenetml-iframe 0.7.0-alpha29 → 0.7.0-alpha30
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 +32 -8
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -26878,7 +26878,7 @@ const mathjaxConfig = {
|
|
|
26878
26878
|
load: ["[tex]/noerrors"]
|
|
26879
26879
|
}
|
|
26880
26880
|
};
|
|
26881
|
-
const viewerIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", () => {\n if (typeof window.renderDoenetViewerToContainer !== "function") {\n return messageParentFromViewer({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n
|
|
26881
|
+
const viewerIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", () => {\n if (typeof window.renderDoenetViewerToContainer !== "function") {\n return messageParentFromViewer({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n const callbackOverrides = {};\n const callbackNames = [\n "reportScoreAndStateCallback",\n "setIsInErrorState",\n "generatedVariantCallback",\n "documentStructureCallback",\n "initializedCallback",\n "setErrorsAndWarningsCallback"\n ];\n for (const callback of callbackNames) {\n callbackOverrides[callback] = haveCallbacks.includes(callback) ? (args) => {\n messageParentFromViewer({\n callback,\n args\n });\n } : void 0;\n }\n window.renderDoenetViewerToContainer(\n document.getElementById("root"),\n void 0,\n {\n ...doenetViewerProps,\n externalVirtualKeyboardProvided: true,\n ...callbackOverrides\n }\n );\n });\n window.addEventListener("message", (e) => {\n var _a, _b;\n if (e.origin !== window.parent.location.origin) {\n return;\n }\n if (((_a = e.data.subject) == null ? void 0 : _a.startsWith("SPLICE")) && !((_b = e.data.subject) == null ? void 0 : _b.endsWith("response"))) {\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';
|
|
26882
26882
|
const editorIframeJsSource = '(function() {\n "use strict";\n document.addEventListener("DOMContentLoaded", () => {\n if (typeof window.renderDoenetEditorToContainer !== "function") {\n return messageParentFromEditor({\n error: "Invalid DoenetML version or DoenetML package not found"\n });\n }\n window.renderDoenetEditorToContainer(\n document.getElementById("root"),\n void 0,\n {\n ...doenetEditorProps,\n externalVirtualKeyboardProvided: true,\n // Callbacks have to be explicitly overridden here so that they\n // can message the parent React component (outside the iframe).\n doenetmlChangeCallback: (args) => {\n messageParentFromEditor({\n callback: "doenetmlChangeCallback",\n args\n });\n },\n immediateDoenetmlChangeCallback: (args) => {\n messageParentFromEditor({\n callback: "immediateDoenetmlChangeCallback",\n args\n });\n }\n }\n );\n });\n function messageParentFromEditor(data) {\n window.parent.postMessage(\n {\n origin: editorId,\n data\n },\n window.parent.origin\n );\n }\n})();\n';
|
|
26883
26883
|
var __defProp$2 = Object.defineProperty;
|
|
26884
26884
|
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
@@ -40129,6 +40129,20 @@ var utils = {
|
|
|
40129
40129
|
canBreak
|
|
40130
40130
|
};
|
|
40131
40131
|
function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneUrl, cssUrl) {
|
|
40132
|
+
const haveCallbacks = [];
|
|
40133
|
+
const callbackNames = [
|
|
40134
|
+
"reportScoreAndStateCallback",
|
|
40135
|
+
"setIsInErrorState",
|
|
40136
|
+
"generatedVariantCallback",
|
|
40137
|
+
"documentStructureCallback",
|
|
40138
|
+
"initializedCallback",
|
|
40139
|
+
"setErrorsAndWarningsCallback"
|
|
40140
|
+
];
|
|
40141
|
+
for (const callback of callbackNames) {
|
|
40142
|
+
if (callback in doenetViewerProps) {
|
|
40143
|
+
haveCallbacks.push(callback);
|
|
40144
|
+
}
|
|
40145
|
+
}
|
|
40132
40146
|
return `
|
|
40133
40147
|
<html style="overflow:hidden">
|
|
40134
40148
|
<head>
|
|
@@ -40139,9 +40153,10 @@ function createHtmlForDoenetViewer(id2, doenetML, doenetViewerProps, standaloneU
|
|
|
40139
40153
|
<script type="module">
|
|
40140
40154
|
const viewerId = "${id2}";
|
|
40141
40155
|
const doenetViewerProps = ${JSON.stringify(doenetViewerProps)};
|
|
40156
|
+
const haveCallbacks = ${JSON.stringify(haveCallbacks)};
|
|
40142
40157
|
|
|
40143
40158
|
// This source code has been compiled by vite and should be directly included.
|
|
40144
|
-
// It assumes that
|
|
40159
|
+
// It assumes that viewerId, doenetViewerProps, and haveCallbacks are defined in the global scope.
|
|
40145
40160
|
${viewerIframeJsSource}
|
|
40146
40161
|
<\/script>
|
|
40147
40162
|
<div id="root">
|
|
@@ -40165,7 +40180,7 @@ function createHtmlForDoenetEditor(id2, doenetML, width, doenetEditorProps, stan
|
|
|
40165
40180
|
const doenetEditorProps = ${JSON.stringify(augmentedProps)};
|
|
40166
40181
|
|
|
40167
40182
|
// This source code has been compiled by vite and should be directly included.
|
|
40168
|
-
// It assumes that
|
|
40183
|
+
// It assumes that editorId and doenetEditorProps are defined in the global scope.
|
|
40169
40184
|
${editorIframeJsSource}
|
|
40170
40185
|
<\/script>
|
|
40171
40186
|
<div id="root">
|
|
@@ -49561,7 +49576,7 @@ function ExternalVirtualKeyboard() {
|
|
|
49561
49576
|
}
|
|
49562
49577
|
);
|
|
49563
49578
|
}
|
|
49564
|
-
const version = "0.7.0-
|
|
49579
|
+
const version = "0.7.0-alpha30";
|
|
49565
49580
|
const latestDoenetmlVersion = version;
|
|
49566
49581
|
function DoenetViewer({
|
|
49567
49582
|
doenetML,
|
|
@@ -49600,7 +49615,7 @@ function DoenetViewer({
|
|
|
49600
49615
|
}
|
|
49601
49616
|
React__default__default.useEffect(() => {
|
|
49602
49617
|
const listener3 = (event) => {
|
|
49603
|
-
var _a, _b, _c, _d, _e2, _f, _g;
|
|
49618
|
+
var _a, _b, _c, _d, _e2, _f, _g, _h, _i;
|
|
49604
49619
|
if (event.origin !== window.location.origin) {
|
|
49605
49620
|
return;
|
|
49606
49621
|
}
|
|
@@ -49616,8 +49631,8 @@ function DoenetViewer({
|
|
|
49616
49631
|
return setInErrorState(data.error);
|
|
49617
49632
|
}
|
|
49618
49633
|
switch (data.callback) {
|
|
49619
|
-
case "
|
|
49620
|
-
return (_d = doenetViewerProps.
|
|
49634
|
+
case "reportScoreAndStateCallback": {
|
|
49635
|
+
return (_d = doenetViewerProps.reportScoreAndStateCallback) == null ? void 0 : _d.call(
|
|
49621
49636
|
doenetViewerProps,
|
|
49622
49637
|
data.args
|
|
49623
49638
|
);
|
|
@@ -49631,8 +49646,17 @@ function DoenetViewer({
|
|
|
49631
49646
|
data.args
|
|
49632
49647
|
);
|
|
49633
49648
|
}
|
|
49649
|
+
case "documentStructureCallback": {
|
|
49650
|
+
return (_g = doenetViewerProps.documentStructureCallback) == null ? void 0 : _g.call(
|
|
49651
|
+
doenetViewerProps,
|
|
49652
|
+
data.args
|
|
49653
|
+
);
|
|
49654
|
+
}
|
|
49655
|
+
case "initializedCallback": {
|
|
49656
|
+
return (_h = doenetViewerProps.initializedCallback) == null ? void 0 : _h.call(doenetViewerProps, data.args);
|
|
49657
|
+
}
|
|
49634
49658
|
case "setErrorsAndWarningsCallback": {
|
|
49635
|
-
return (
|
|
49659
|
+
return (_i = doenetViewerProps.setErrorsAndWarningsCallback) == null ? void 0 : _i.call(
|
|
49636
49660
|
doenetViewerProps,
|
|
49637
49661
|
data.args
|
|
49638
49662
|
);
|