@pie-element/math-inline 5.9.11 → 6.1.0

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.
@@ -518,6 +518,27 @@
518
518
  }
519
519
  }
520
520
  },
521
+ "ConfigureMaxImageDimensionsProp": {
522
+ "title": "ConfigureMaxImageDimensionsProp",
523
+ "type": "object",
524
+ "properties": {
525
+ "teacherInstructions": {
526
+ "description": "Indicates the max dimension for images in teacher instructions",
527
+ "type": "number",
528
+ "title": "teacherInstructions"
529
+ },
530
+ "prompt": {
531
+ "description": "Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified",
532
+ "type": "number",
533
+ "title": "prompt"
534
+ },
535
+ "rationale": {
536
+ "description": "Indicates the max dimension for images in rationale",
537
+ "type": "number",
538
+ "title": "rationale"
539
+ }
540
+ }
541
+ },
521
542
  "ComplexFeedbackType": {
522
543
  "title": "ComplexFeedbackType",
523
544
  "type": "object",
@@ -266,6 +266,22 @@ Indicates the label for the item that has to be displayed in the Settings Panel
266
266
  Indicates the value of the item if it affects config-ui
267
267
  (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
268
268
 
269
+ ## `ConfigureMaxImageDimensionsProp` (object)
270
+
271
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
272
+
273
+ ### `teacherInstructions` (number)
274
+
275
+ Indicates the max dimension for images in teacher instructions
276
+
277
+ ### `prompt` (number)
278
+
279
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
280
+
281
+ ### `rationale` (number)
282
+
283
+ Indicates the max dimension for images in rationale
284
+
269
285
  ## `ComplexFeedbackType` (object)
270
286
 
271
287
  Properties of the `ComplexFeedbackType` object:
@@ -44,39 +44,47 @@ var SimpleQuestionBlockRaw = /*#__PURE__*/function (_React$Component) {
44
44
 
45
45
  var _super = _createSuper(SimpleQuestionBlockRaw);
46
46
 
47
- function SimpleQuestionBlockRaw() {
47
+ function SimpleQuestionBlockRaw(props) {
48
48
  var _this;
49
49
 
50
50
  (0, _classCallCheck2["default"])(this, SimpleQuestionBlockRaw);
51
-
52
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
53
- args[_key] = arguments[_key];
54
- }
55
-
56
- _this = _super.call.apply(_super, [this].concat(args));
57
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
58
- showKeypad: true
51
+ _this = _super.call(this, props);
52
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "mathToolBarContainsTarget", function (e) {
53
+ return document.getElementById(_this.mathToolBarId).contains(e.target);
54
+ });
55
+ (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "handleClick", function (e) {
56
+ try {
57
+ if (!_this.mathToolBarContainsTarget(e)) {
58
+ _this.setState({
59
+ showKeypad: false
60
+ });
61
+ }
62
+ } catch (e) {// console.log(e.toString());
63
+ }
59
64
  });
60
65
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onFocus", function () {
61
66
  return _this.setState({
62
67
  showKeypad: true
63
68
  });
64
69
  });
65
- (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onBlur", function (e) {
66
- var _ref = e || {},
67
- relatedTarget = _ref.relatedTarget,
68
- currentTarget = _ref.currentTarget;
69
-
70
- if (!relatedTarget || !currentTarget || relatedTarget.offsetParent !== currentTarget.offsetParent) {
71
- _this.setState({
72
- showKeypad: false
73
- });
74
- }
75
- });
70
+ _this.state = {
71
+ showKeypad: true
72
+ };
73
+ _this.mathToolBarId = "math-toolbar-".concat(new Date().getTime());
76
74
  return _this;
77
75
  }
78
76
 
79
77
  (0, _createClass2["default"])(SimpleQuestionBlockRaw, [{
78
+ key: "componentDidMount",
79
+ value: function componentDidMount() {
80
+ window.addEventListener('click', this.handleClick);
81
+ }
82
+ }, {
83
+ key: "componentWillUnmount",
84
+ value: function componentWillUnmount() {
85
+ window.removeEventListener('click', this.handleClick);
86
+ }
87
+ }, {
80
88
  key: "render",
81
89
  value: function render() {
82
90
  var _cx;
@@ -89,19 +97,16 @@ var SimpleQuestionBlockRaw = /*#__PURE__*/function (_React$Component) {
89
97
  emptyResponse = _this$props.emptyResponse,
90
98
  onSimpleResponseChange = _this$props.onSimpleResponseChange;
91
99
 
92
- var _ref2 = model || {},
93
- config = _ref2.config,
94
- disabled = _ref2.disabled,
95
- correctness = _ref2.correctness,
96
- view = _ref2.view;
100
+ var _ref = model || {},
101
+ config = _ref.config,
102
+ disabled = _ref.disabled,
103
+ correctness = _ref.correctness;
97
104
 
98
105
  if (!config) {
99
106
  return;
100
107
  }
101
108
 
102
109
  var correct = correctness && correctness.correct;
103
- var showAsCorrect = !emptyResponse && (showCorrect || correct);
104
- var showAsIncorrect = !emptyResponse && !correct && !showCorrect && !view;
105
110
  var responses = config.responses,
106
111
  equationEditor = config.equationEditor;
107
112
  return /*#__PURE__*/_react["default"].createElement("div", {
@@ -110,7 +115,9 @@ var SimpleQuestionBlockRaw = /*#__PURE__*/function (_React$Component) {
110
115
  className: (0, _classnames["default"])(classes["static"], (_cx = {}, (0, _defineProperty2["default"])(_cx, classes.incorrect, !emptyResponse && !correct && !showCorrect), (0, _defineProperty2["default"])(_cx, classes.correct, !emptyResponse && (correct || showCorrect)), _cx))
111
116
  }, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
112
117
  latex: showCorrect ? responses && responses.length && responses[0].answer : session.response || ''
113
- })) : /*#__PURE__*/_react["default"].createElement(_mathToolbar.MathToolbar, {
118
+ })) : /*#__PURE__*/_react["default"].createElement("div", {
119
+ id: this.mathToolBarId
120
+ }, /*#__PURE__*/_react["default"].createElement(_mathToolbar.MathToolbar, {
114
121
  classNames: {
115
122
  editor: classes.responseEditor
116
123
  },
@@ -119,11 +126,10 @@ var SimpleQuestionBlockRaw = /*#__PURE__*/function (_React$Component) {
119
126
  onChange: onSimpleResponseChange,
120
127
  onDone: function onDone() {},
121
128
  onFocus: this.onFocus,
122
- onBlur: this.onBlur,
123
129
  controlledKeypad: true,
124
130
  showKeypad: this.state.showKeypad,
125
131
  hideDoneButton: true
126
- }));
132
+ })));
127
133
  }
128
134
  }]);
129
135
  return SimpleQuestionBlockRaw;
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/simple-question-block.jsx"],"names":["SimpleQuestionBlockRaw","showKeypad","setState","e","relatedTarget","currentTarget","offsetParent","props","classes","model","showCorrect","session","emptyResponse","onSimpleResponseChange","config","disabled","correctness","view","correct","showAsCorrect","showAsIncorrect","responses","equationEditor","expression","incorrect","length","answer","response","editor","responseEditor","onFocus","onBlur","state","React","Component","PropTypes","object","func","isRequired","bool","SimpleQuestionBlock","theme","display","justifyContent","width","maxWidth","height","textAlign","padding","spacing","unit","border","color","primaryLight","marginTop","marginBottom","text","background","fontSize","letterSpacing"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,sB;;;;;;;;;;;;;;;8FAUH;AACNC,MAAAA,UAAU,EAAE;AADN,K;gGAIE;AAAA,aAAM,MAAKC,QAAL,CAAc;AAAED,QAAAA,UAAU,EAAE;AAAd,OAAd,CAAN;AAAA,K;+FAED,UAACE,CAAD,EAAO;AACd,iBAAyCA,CAAC,IAAI,EAA9C;AAAA,UAAQC,aAAR,QAAQA,aAAR;AAAA,UAAuBC,aAAvB,QAAuBA,aAAvB;;AAEA,UAAI,CAACD,aAAD,IAAkB,CAACC,aAAnB,IAAqCD,aAAa,CAACE,YAAd,KAA+BD,aAAa,CAACC,YAAtF,EAAqG;AACnG,cAAKJ,QAAL,CAAc;AAAED,UAAAA,UAAU,EAAE;AAAd,SAAd;AACD;AACF,K;;;;;;WAED,kBAAS;AAAA;;AACP,wBAOI,KAAKM,KAPT;AAAA,UACEC,OADF,eACEA,OADF;AAAA,UAEEC,KAFF,eAEEA,KAFF;AAAA,UAGEC,WAHF,eAGEA,WAHF;AAAA,UAIEC,OAJF,eAIEA,OAJF;A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AAEVK,MAAAA,YAAY,EAAEd,KAAK,CAACQ,OAAN,CAAcC,IAAd,GAAqB,CAFzB;AAGVF,MAAAA,OAAO,EAAEP,KAAK,CAACQ,OAAN,CAAcC;AAHb,KAbmC;AAkB/C,cAAQ;AACNE,MAAAA,KAAK,EAAEA,gBAAMI,IAAN,EADD;AAENC,MAAAA,UAAU,EAAEL,gBAAMK,UAAN,EAFN;AAGNN,MAAAA,MAAM,sBAAeC,gBAAMC,YAAN,EAAf,CAHA;AAINT,MAAAA,KAAK,EAAE,aAJD;AAKNc,MAAAA,QAAQ,EAAE,MALJ;AAMNV,MAAAA,OAAO,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAAd,GAAqB,CANxB;AAON,2BAAqB;AACnB,6BAAqB;AACnB,4BAAkB;AAChBR,YAAAA,OAAO,EAAE;AADO;AADC;AADF;AAPf,KAlBuC;AAiC/CxB,IAAAA,OAAO,EAAE;AACPiC,MAAAA,MAAM,sBAAeC,gBAAMlC,OAAN,EAAf,gBADC;AAEP8B,MAAAA,OAAO,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAFhB;AAGPS,MAAAA,aAAa,EAAE;AAHR,KAjCsC;AAsC/CnC,IAAAA,SAAS,EAAE;AACT2B,MAAAA,MAAM,sBAAeC,gBAAM5B,SAAN,EAAf,gBADG;AAETwB,MAAAA,OAAO,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAFd;AAGTS,MAAAA,aAAa,EAAE;AAHN;AAtCoC,GAAL;AAAA,CAAhB,EA2CxB3D,sBA3CwB,CAA5B;eA6CewC,mB","sourcesContent":["import React from 'react';\nimport { MathToolbar } from '@pie-lib/math-toolbar';\nimport { mq } from '@pie-lib/math-input';\nimport cx from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport { color } from '@pie-lib/render-ui';\n\nexport class SimpleQuestionBlockRaw extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n onSimpleResponseChange: PropTypes.func,\n model: PropTypes.object.isRequired,\n emptyResponse: PropTypes.bool,\n session: PropTypes.object.isRequired,\n showCorrect: PropTypes.bool\n };\n\n state = {\n showKeypad: true\n };\n\n onFocus = () => this.setState({ showKeypad: true });\n\n onBlur = (e) => {\n const { relatedTarget, currentTarget } = e || {};\n\n if (!relatedTarget || !currentTarget || (relatedTarget.offsetParent !== currentTarget.offsetParent)) {\n this.setState({ showKeypad: false });\n }\n };\n\n render() {\n const {\n classes,\n model,\n showCorrect,\n session,\n emptyResponse,\n onSimpleResponseChange\n } = this.props;\n const { config, disabled, correctness, view } = model || {};\n\n if (!config) {\n return;\n }\n\n const correct = correctness && correctness.correct;\n const showAsCorrect = !emptyResponse && (showCorrect || correct);\n const showAsIncorrect = !emptyResponse && !correct && !showCorrect && !view;\n const { responses, equationEditor } = config;\n\n return (\n <div className={classes.expression}>\n {showCorrect || disabled ? (\n <div\n className={cx(classes.static, {\n [classes.incorrect]: !emptyResponse && !correct && !showCorrect,\n [classes.correct]: !emptyResponse && (correct || showCorrect)\n })}\n >\n <mq.Static\n latex={\n showCorrect ? (responses && responses.length && responses[0].answer) : (session.response || '')\n }\n />\n </div>\n ) : (\n <MathToolbar\n classNames={{ editor: classes.responseEditor }}\n latex={session.response || ''}\n keypadMode={equationEditor}\n onChange={onSimpleResponseChange}\n onDone={() => {}}\n onFocus={this.onFocus}\n onBlur={this.onBlur}\n controlledKeypad={true}\n showKeypad={this.state.showKeypad}\n hideDoneButton={true}\n />\n )}\n </div>\n );\n }\n}\nconst SimpleQuestionBlock = withStyles(theme => ({\n responseEditor: {\n display: 'flex',\n justifyContent: 'center',\n width: 'auto',\n maxWidth: 'fit-content',\n height: 'auto',\n textAlign: 'left',\n padding: theme.spacing.unit,\n '&.mq-math-mode': {\n border: `1px solid ${color.primaryLight()}`\n }\n },\n expression: {\n marginTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n padding: theme.spacing.unit\n },\n static: {\n color: color.text(),\n background: color.background(),\n border: `1px solid ${color.primaryLight()}`,\n width: 'fit-content',\n fontSize: '1rem',\n padding: theme.spacing.unit / 2,\n '& > .mq-math-mode': {\n '& > .mq-hasCursor': {\n '& > .mq-cursor': {\n display: 'none'\n }\n }\n }\n },\n correct: {\n border: `2px solid ${color.correct()} !important`,\n padding: theme.spacing.unit,\n letterSpacing: '0.5px',\n },\n incorrect: {\n border: `2px solid ${color.incorrect()} !important`,\n padding: theme.spacing.unit,\n letterSpacing: '0.5px',\n }\n}))(SimpleQuestionBlockRaw);\n\nexport default SimpleQuestionBlock;\n"],"file":"simple-question-block.js"}
1
+ {"version":3,"sources":["../src/simple-question-block.jsx"],"names":["SimpleQuestionBlockRaw","props","e","document","getElementById","mathToolBarId","contains","target","mathToolBarContainsTarget","setState","showKeypad","state","Date","getTime","window","addEventListener","handleClick","removeEventListener","classes","model","showCorrect","session","emptyResponse","onSimpleResponseChange","config","disabled","correctness","correct","responses","equationEditor","expression","incorrect","length","answer","response","editor","responseEditor","onFocus","React","Component","PropTypes","object","func","isRequired","bool","SimpleQuestionBlock","theme","display","justifyContent","width","maxWidth","height","textAlign","padding","spacing","unit","border","color","primaryLight","marginTop","marginBottom","text","background","fontSize","letterSpacing"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;IAEaA,sB;;;;;AAUX,kCAAYC,KAAZ,EAAmB;AAAA;;AAAA;AACjB,8BAAMA,KAAN;AADiB,kHAiBS,UAAAC,CAAC;AAAA,aAAIC,QAAQ,CAACC,cAAT,CAAwB,MAAKC,aAA7B,EAA4CC,QAA5C,CAAqDJ,CAAC,CAACK,MAAvD,CAAJ;AAAA,KAjBV;AAAA,oGAmBL,UAACL,CAAD,EAAO;AACnB,UAAI;AACF,YAAI,CAAC,MAAKM,yBAAL,CAA+BN,CAA/B,CAAL,EAAwC;AACtC,gBAAKO,QAAL,CAAc;AAAEC,YAAAA,UAAU,EAAE;AAAd,WAAd;AACD;AACF,OA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AM,sBAAeC,gBAAM1B,SAAN,EAAf,gBADG;AAETsB,MAAAA,OAAO,EAAEP,KAAK,CAACQ,OAAN,CAAcC,IAFd;AAGTS,MAAAA,aAAa,EAAE;AAHN;AAtCoC,GAAL;AAAA,CAAhB,EA2CxBhE,sBA3CwB,CAA5B;eA6Ce6C,mB","sourcesContent":["import React from 'react';\nimport { MathToolbar } from '@pie-lib/math-toolbar';\nimport { mq } from '@pie-lib/math-input';\nimport cx from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport { color } from '@pie-lib/render-ui';\n\nexport class SimpleQuestionBlockRaw extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n onSimpleResponseChange: PropTypes.func,\n model: PropTypes.object.isRequired,\n emptyResponse: PropTypes.bool,\n session: PropTypes.object.isRequired,\n showCorrect: PropTypes.bool\n };\n\n constructor(props) {\n super(props);\n\n this.state = {\n showKeypad: true\n };\n this.mathToolBarId = `math-toolbar-${new Date().getTime()}`;\n }\n\n componentDidMount() {\n window.addEventListener('click', this.handleClick);\n }\n\n componentWillUnmount() {\n window.removeEventListener('click', this.handleClick);\n }\n\n mathToolBarContainsTarget = e => document.getElementById(this.mathToolBarId).contains(e.target);\n\n handleClick = (e) => {\n try {\n if (!this.mathToolBarContainsTarget(e)) {\n this.setState({ showKeypad: false });\n }\n } catch (e) {\n // console.log(e.toString());\n }\n }\n\n onFocus = () => this.setState({ showKeypad: true })\n\n render() {\n const {\n classes,\n model,\n showCorrect,\n session,\n emptyResponse,\n onSimpleResponseChange\n } = this.props;\n const { config, disabled, correctness } = model || {};\n\n if (!config) {\n return;\n }\n\n const correct = correctness && correctness.correct;\n const { responses, equationEditor } = config;\n\n return (\n <div className={classes.expression}>\n {showCorrect || disabled ? (\n <div\n className={cx(classes.static, {\n [classes.incorrect]: !emptyResponse && !correct && !showCorrect,\n [classes.correct]: !emptyResponse && (correct || showCorrect)\n })}\n >\n <mq.Static\n latex={\n showCorrect ? (responses && responses.length && responses[0].answer) : (session.response || '')\n }\n />\n </div>\n ) : (\n <div id={this.mathToolBarId}>\n <MathToolbar\n classNames={{ editor: classes.responseEditor }}\n latex={session.response || ''}\n keypadMode={equationEditor}\n onChange={onSimpleResponseChange}\n onDone={() => {\n }}\n onFocus={this.onFocus}\n controlledKeypad={true}\n showKeypad={this.state.showKeypad}\n hideDoneButton={true}\n />\n </div>\n )}\n </div>\n );\n }\n}\n\nconst SimpleQuestionBlock = withStyles(theme => ({\n responseEditor: {\n display: 'flex',\n justifyContent: 'center',\n width: 'auto',\n maxWidth: 'fit-content',\n height: 'auto',\n textAlign: 'left',\n padding: theme.spacing.unit,\n '&.mq-math-mode': {\n border: `1px solid ${color.primaryLight()}`\n }\n },\n expression: {\n marginTop: theme.spacing.unit * 2,\n marginBottom: theme.spacing.unit * 2,\n padding: theme.spacing.unit\n },\n static: {\n color: color.text(),\n background: color.background(),\n border: `1px solid ${color.primaryLight()}`,\n width: 'fit-content',\n fontSize: '1rem',\n padding: theme.spacing.unit / 2,\n '& > .mq-math-mode': {\n '& > .mq-hasCursor': {\n '& > .mq-cursor': {\n display: 'none'\n }\n }\n }\n },\n correct: {\n border: `2px solid ${color.correct()} !important`,\n padding: theme.spacing.unit,\n letterSpacing: '0.5px',\n },\n incorrect: {\n border: `2px solid ${color.incorrect()} !important`,\n padding: theme.spacing.unit,\n letterSpacing: '0.5px',\n }\n}))(SimpleQuestionBlockRaw);\n\nexport default SimpleQuestionBlock;\n"],"file":"simple-question-block.js"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "5.9.11",
7
+ "version": "6.1.0",
8
8
  "main": "lib/index.js",
9
9
  "description": "",
10
10
  "scripts": {
@@ -15,10 +15,10 @@
15
15
  "@material-ui/core": "^3.9.2",
16
16
  "@pie-framework/mathquill": "^1.1.0",
17
17
  "@pie-framework/pie-player-events": "^0.1.0",
18
- "@pie-lib/correct-answer-toggle": "^2.3.38",
19
- "@pie-lib/math-input": "^6.6.9",
20
- "@pie-lib/math-toolbar": "^1.9.3",
21
- "@pie-lib/render-ui": "^4.12.8",
18
+ "@pie-lib/correct-answer-toggle": "^2.3.39",
19
+ "@pie-lib/math-input": "^6.6.10",
20
+ "@pie-lib/math-toolbar": "^1.9.4",
21
+ "@pie-lib/render-ui": "^4.12.9",
22
22
  "classnames": "^2.2.5",
23
23
  "debug": "^4.1.1",
24
24
  "lodash": "^4.17.10",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "author": "",
30
30
  "license": "ISC",
31
- "gitHead": "3f3d6edc68890098821978ebd5a8b90da31ab222",
31
+ "gitHead": "9b55e36b358084c7a96a08bad969f4856d6802da",
32
32
  "module": "src/index.js",
33
33
  "exports": {
34
34
  ".": "./src/index.js",