@doenet/doenetml-iframe 0.7.0-alpha16 → 0.7.0-alpha18

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.d.ts CHANGED
@@ -49,7 +49,7 @@ export declare type DoenetEditorIframeProps = DoenetEditorProps & {
49
49
  height?: string;
50
50
  };
51
51
 
52
- declare type DoenetEditorProps = Omit<React.ComponentProps<typeof DoenetEditor_2>, "doenetML" | "width" | "height" | "keyboardIsOutsideIframe">;
52
+ declare type DoenetEditorProps = Omit<React.ComponentProps<typeof DoenetEditor_2>, "doenetML" | "width" | "height" | "externalVirtualKeyboardProvided">;
53
53
 
54
54
  /**
55
55
  * Render Doenet viewer constrained to an iframe. A URL pointing to a version of DoenetML
@@ -87,7 +87,7 @@ export declare type DoenetViewerIframeProps = DoenetViewerProps & {
87
87
  autodetectVersion?: boolean;
88
88
  };
89
89
 
90
- declare type DoenetViewerProps = Omit<React.ComponentProps<typeof DoenetViewer_2>, "doenetML" | "scrollableContainer" | "keyboardIsOutsideIframe">;
90
+ declare type DoenetViewerProps = Omit<React.ComponentProps<typeof DoenetViewer_2>, "doenetML" | "scrollableContainer" | "externalVirtualKeyboardProvided">;
91
91
 
92
92
  export { ErrorDescription }
93
93
 
package/index.js CHANGED
@@ -27925,8 +27925,8 @@ const mathjaxConfig = {
27925
27925
  displayMath: [["\\[", "\\]"]]
27926
27926
  }
27927
27927
  };
27928
- 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 window.renderDoenetViewerToContainer(\n document.getElementById("root"),\n void 0,\n {\n ...doenetViewerProps,\n keyboardIsOutsideIframe: true,\n // Callbacks have to be explicitly overridden here so that they\n // can message the parent React component (outside the iframe).\n updateCreditAchievedCallback: (args) => {\n messageParentFromViewer({\n callback: "updateCreditAchievedCallback",\n args\n });\n },\n updateActivityStatusCallback: (args) => {\n messageParentFromViewer({\n callback: "updateActivityStatusCallback",\n args\n });\n },\n updateAttemptNumber: (args) => {\n messageParentFromViewer({\n callback: "updateAttemptNumber",\n args\n });\n },\n pageChangedCallback: (args) => {\n messageParentFromViewer({\n callback: "pageChangedCallback",\n args\n });\n },\n cidChangedCallback: (args) => {\n messageParentFromViewer({\n callback: "cidChangedCallback",\n args\n });\n },\n checkIfCidChanged: (args) => {\n messageParentFromViewer({\n callback: "checkIfCidChanged",\n args\n });\n },\n setActivityAsCompleted: (args) => {\n messageParentFromViewer({\n callback: "setActivityAsCompleted",\n args\n });\n },\n setIsInErrorState: (args) => {\n messageParentFromViewer({\n callback: "setIsInErrorState",\n args\n });\n },\n generatedVariantCallback: (args) => {\n messageParentFromViewer({\n callback: "generatedVariantCallback",\n args\n });\n },\n setErrorsAndWarningsCallback: (args) => {\n messageParentFromViewer({\n callback: "setErrorsAndWarningsCallback",\n args\n });\n }\n }\n );\n });\n window.addEventListener("message", (e) => {\n if (e.data.subject.startsWith("SPLICE") && !e.data.subject.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';
27929
- 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 keyboardIsOutsideIframe: 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';
27928
+ 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 window.renderDoenetViewerToContainer(\n document.getElementById("root"),\n void 0,\n {\n ...doenetViewerProps,\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 updateCreditAchievedCallback: (args) => {\n messageParentFromViewer({\n callback: "updateCreditAchievedCallback",\n args\n });\n },\n updateActivityStatusCallback: (args) => {\n messageParentFromViewer({\n callback: "updateActivityStatusCallback",\n args\n });\n },\n updateAttemptNumber: (args) => {\n messageParentFromViewer({\n callback: "updateAttemptNumber",\n args\n });\n },\n pageChangedCallback: (args) => {\n messageParentFromViewer({\n callback: "pageChangedCallback",\n args\n });\n },\n cidChangedCallback: (args) => {\n messageParentFromViewer({\n callback: "cidChangedCallback",\n args\n });\n },\n checkIfCidChanged: (args) => {\n messageParentFromViewer({\n callback: "checkIfCidChanged",\n args\n });\n },\n setActivityAsCompleted: (args) => {\n messageParentFromViewer({\n callback: "setActivityAsCompleted",\n args\n });\n },\n setIsInErrorState: (args) => {\n messageParentFromViewer({\n callback: "setIsInErrorState",\n args\n });\n },\n generatedVariantCallback: (args) => {\n messageParentFromViewer({\n callback: "generatedVariantCallback",\n args\n });\n },\n setErrorsAndWarningsCallback: (args) => {\n messageParentFromViewer({\n callback: "setErrorsAndWarningsCallback",\n args\n });\n }\n }\n );\n });\n window.addEventListener("message", (e) => {\n if (e.data.subject.startsWith("SPLICE") && !e.data.subject.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';
27929
+ 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';
27930
27930
  var __defProp$2 = Object.defineProperty;
27931
27931
  var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
27932
27932
  var __publicField = (obj, key, value) => __defNormalProp$2(obj, key + "", value);
@@ -50738,18 +50738,13 @@ function KeyboardTray({ onClick }) {
50738
50738
  document.body
50739
50739
  );
50740
50740
  }
50741
- let virtualKeyboardState;
50742
- if (window.virtualKeyboardState) {
50743
- virtualKeyboardState = window.virtualKeyboardState;
50744
- } else {
50745
- virtualKeyboardState = {
50746
- count: 0,
50747
- keyboardDomNode: null,
50748
- keyboardReactRoot: null,
50749
- callbacks: []
50750
- };
50751
- window.virtualKeyboardState = virtualKeyboardState;
50752
- }
50741
+ const virtualKeyboardState = window.virtualKeyboardState || {
50742
+ count: 0,
50743
+ keyboardDomNode: null,
50744
+ keyboardReactRoot: null,
50745
+ callbacks: []
50746
+ };
50747
+ window.virtualKeyboardState = virtualKeyboardState;
50753
50748
  function UniqueKeyboardTray({ onClick }) {
50754
50749
  React__default__default.useEffect(() => {
50755
50750
  if (virtualKeyboardState.count === 0) {
@@ -50795,7 +50790,7 @@ function UniqueKeyboardTray({ onClick }) {
50795
50790
  }, []);
50796
50791
  return null;
50797
50792
  }
50798
- function OutsideIframeKeyboard() {
50793
+ function ExternalVirtualKeyboard() {
50799
50794
  return /* @__PURE__ */ React__default__default.createElement(
50800
50795
  UniqueKeyboardTray,
50801
50796
  {
@@ -50808,7 +50803,7 @@ function OutsideIframeKeyboard() {
50808
50803
  }
50809
50804
  );
50810
50805
  }
50811
- const version = "0.7.0-alpha16";
50806
+ const version = "0.7.0-alpha18";
50812
50807
  const latestDoenetmlVersion = version;
50813
50808
  function DoenetViewer({
50814
50809
  doenetML,
@@ -50833,6 +50828,7 @@ function DoenetViewer({
50833
50828
  detectedVersion = result2.version;
50834
50829
  }
50835
50830
  }
50831
+ const addVirtualKeyboard = doenetViewerProps.addVirtualKeyboard !== false;
50836
50832
  let selectedDoenetmlVersion = detectedVersion ?? specifiedDoenetmlVersion ?? latestDoenetmlVersion;
50837
50833
  if (specifiedStandaloneUrl && !foundAutoVersion) {
50838
50834
  standaloneUrl = specifiedStandaloneUrl;
@@ -50936,7 +50932,7 @@ function DoenetViewer({
50936
50932
  inErrorState
50937
50933
  );
50938
50934
  }
50939
- return /* @__PURE__ */ React__default__default.createElement(React__default__default.Fragment, null, /* @__PURE__ */ React__default__default.createElement(OutsideIframeKeyboard, null), /* @__PURE__ */ React__default__default.createElement(
50935
+ return /* @__PURE__ */ React__default__default.createElement(React__default__default.Fragment, null, addVirtualKeyboard ? /* @__PURE__ */ React__default__default.createElement(ExternalVirtualKeyboard, null) : null, /* @__PURE__ */ React__default__default.createElement(
50940
50936
  "iframe",
50941
50937
  {
50942
50938
  ref,
@@ -50993,6 +50989,7 @@ function DoenetEditor({
50993
50989
  detectedDoenetMLrange = result2.doenetMLrange;
50994
50990
  }
50995
50991
  }
50992
+ const addVirtualKeyboard = doenetEditorProps.addVirtualKeyboard !== false;
50996
50993
  let selectedDoenetmlVersion = detectedVersion ?? specifiedDoenetmlVersion ?? latestDoenetmlVersion;
50997
50994
  if (specifiedStandaloneUrl && !foundAutoVersion) {
50998
50995
  standaloneUrl = specifiedStandaloneUrl;
@@ -51069,7 +51066,7 @@ function DoenetEditor({
51069
51066
  inErrorState
51070
51067
  );
51071
51068
  }
51072
- return /* @__PURE__ */ React__default__default.createElement(React__default__default.Fragment, null, /* @__PURE__ */ React__default__default.createElement(OutsideIframeKeyboard, null), /* @__PURE__ */ React__default__default.createElement(
51069
+ return /* @__PURE__ */ React__default__default.createElement(React__default__default.Fragment, null, addVirtualKeyboard ? /* @__PURE__ */ React__default__default.createElement(ExternalVirtualKeyboard, null) : null, /* @__PURE__ */ React__default__default.createElement(
51073
51070
  "iframe",
51074
51071
  {
51075
51072
  ref,