@pie-element/extended-text-entry 6.5.4-next.135 → 6.5.4-next.1353

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.
@@ -35,6 +35,38 @@
35
35
  }
36
36
  }
37
37
  },
38
+ "spanishInput": {
39
+ "title": "ConfigureProp",
40
+ "type": "object",
41
+ "properties": {
42
+ "settings": {
43
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
44
+ "type": "boolean",
45
+ "title": "settings"
46
+ },
47
+ "label": {
48
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
49
+ "type": "string",
50
+ "title": "label"
51
+ }
52
+ }
53
+ },
54
+ "specialInput": {
55
+ "title": "ConfigureProp",
56
+ "type": "object",
57
+ "properties": {
58
+ "settings": {
59
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
60
+ "type": "boolean",
61
+ "title": "settings"
62
+ },
63
+ "label": {
64
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
65
+ "type": "string",
66
+ "title": "label"
67
+ }
68
+ }
69
+ },
38
70
  "multiple": {
39
71
  "title": "ConfigurePropWithEnabled",
40
72
  "type": "object",
@@ -88,6 +120,38 @@
88
120
  }
89
121
  }
90
122
  },
123
+ "spellCheck": {
124
+ "title": "ConfigureProp",
125
+ "type": "object",
126
+ "properties": {
127
+ "settings": {
128
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
129
+ "type": "boolean",
130
+ "title": "settings"
131
+ },
132
+ "label": {
133
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
134
+ "type": "string",
135
+ "title": "label"
136
+ }
137
+ }
138
+ },
139
+ "playerSpellCheck": {
140
+ "title": "ConfigureProp",
141
+ "type": "object",
142
+ "properties": {
143
+ "settings": {
144
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
145
+ "type": "boolean",
146
+ "title": "settings"
147
+ },
148
+ "label": {
149
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
150
+ "type": "string",
151
+ "title": "label"
152
+ }
153
+ }
154
+ },
91
155
  "dimensions": {
92
156
  "title": "ConfigureProp",
93
157
  "type": "object",
@@ -104,6 +168,64 @@
104
168
  }
105
169
  }
106
170
  },
171
+ "maxImageWidth": {
172
+ "title": "ConfigureMaxImageDimensionsProp",
173
+ "type": "object",
174
+ "properties": {
175
+ "teacherInstructions": {
176
+ "description": "Indicates the max dimension for images in teacher instructions",
177
+ "type": "number",
178
+ "title": "teacherInstructions"
179
+ },
180
+ "prompt": {
181
+ "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",
182
+ "type": "number",
183
+ "title": "prompt"
184
+ },
185
+ "rationale": {
186
+ "description": "Indicates the max dimension for images in rationale",
187
+ "type": "number",
188
+ "title": "rationale"
189
+ }
190
+ }
191
+ },
192
+ "maxImageHeight": {
193
+ "title": "ConfigureMaxImageDimensionsProp",
194
+ "type": "object",
195
+ "properties": {
196
+ "teacherInstructions": {
197
+ "description": "Indicates the max dimension for images in teacher instructions",
198
+ "type": "number",
199
+ "title": "teacherInstructions"
200
+ },
201
+ "prompt": {
202
+ "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",
203
+ "type": "number",
204
+ "title": "prompt"
205
+ },
206
+ "rationale": {
207
+ "description": "Indicates the max dimension for images in rationale",
208
+ "type": "number",
209
+ "title": "rationale"
210
+ }
211
+ }
212
+ },
213
+ "withRubric": {
214
+ "title": "ConfigureProp",
215
+ "type": "object",
216
+ "properties": {
217
+ "settings": {
218
+ "description": "Indicates if the item has to be displayed in the Settings Panel",
219
+ "type": "boolean",
220
+ "title": "settings"
221
+ },
222
+ "label": {
223
+ "description": "Indicates the label for the item that has to be displayed in the Settings Panel",
224
+ "type": "string",
225
+ "title": "label"
226
+ }
227
+ }
228
+ },
107
229
  "showPrompt": {
108
230
  "description": "Determines whether prompt field will be displayed or not",
109
231
  "default": true,
@@ -160,6 +282,27 @@
160
282
  "title": "enabled"
161
283
  }
162
284
  }
285
+ },
286
+ "ConfigureMaxImageDimensionsProp": {
287
+ "title": "ConfigureMaxImageDimensionsProp",
288
+ "type": "object",
289
+ "properties": {
290
+ "teacherInstructions": {
291
+ "description": "Indicates the max dimension for images in teacher instructions",
292
+ "type": "number",
293
+ "title": "teacherInstructions"
294
+ },
295
+ "prompt": {
296
+ "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",
297
+ "type": "number",
298
+ "title": "prompt"
299
+ },
300
+ "rationale": {
301
+ "description": "Indicates the max dimension for images in rationale",
302
+ "type": "number",
303
+ "title": "rationale"
304
+ }
305
+ }
163
306
  }
164
307
  },
165
308
  "$schema": "http://json-schema.org/draft-07/schema#"
@@ -26,6 +26,30 @@ Indicates if the item has to be displayed in the Settings Panel
26
26
 
27
27
  Indicates the label for the item that has to be displayed in the Settings Panel
28
28
 
29
+ # `spanishInput` (object)
30
+
31
+ Properties of the `spanishInput` object:
32
+
33
+ ## `settings` (boolean)
34
+
35
+ Indicates if the item has to be displayed in the Settings Panel
36
+
37
+ ## `label` (string)
38
+
39
+ Indicates the label for the item that has to be displayed in the Settings Panel
40
+
41
+ # `specialInput` (object)
42
+
43
+ Properties of the `specialInput` object:
44
+
45
+ ## `settings` (boolean)
46
+
47
+ Indicates if the item has to be displayed in the Settings Panel
48
+
49
+ ## `label` (string)
50
+
51
+ Indicates the label for the item that has to be displayed in the Settings Panel
52
+
29
53
  # `multiple` (object)
30
54
 
31
55
  Properties of the `multiple` object:
@@ -67,6 +91,30 @@ Indicates if the item has to be displayed in the Settings Panel
67
91
 
68
92
  Indicates the label for the item that has to be displayed in the Settings Panel
69
93
 
94
+ # `spellCheck` (object)
95
+
96
+ Properties of the `spellCheck` object:
97
+
98
+ ## `settings` (boolean)
99
+
100
+ Indicates if the item has to be displayed in the Settings Panel
101
+
102
+ ## `label` (string)
103
+
104
+ Indicates the label for the item that has to be displayed in the Settings Panel
105
+
106
+ # `playerSpellCheck` (object)
107
+
108
+ Properties of the `playerSpellCheck` object:
109
+
110
+ ## `settings` (boolean)
111
+
112
+ Indicates if the item has to be displayed in the Settings Panel
113
+
114
+ ## `label` (string)
115
+
116
+ Indicates the label for the item that has to be displayed in the Settings Panel
117
+
70
118
  # `dimensions` (object)
71
119
 
72
120
  Properties of the `dimensions` object:
@@ -79,6 +127,50 @@ Indicates if the item has to be displayed in the Settings Panel
79
127
 
80
128
  Indicates the label for the item that has to be displayed in the Settings Panel
81
129
 
130
+ # `maxImageWidth` (object)
131
+
132
+ Properties of the `maxImageWidth` object:
133
+
134
+ ## `teacherInstructions` (number)
135
+
136
+ Indicates the max dimension for images in teacher instructions
137
+
138
+ ## `prompt` (number)
139
+
140
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
141
+
142
+ ## `rationale` (number)
143
+
144
+ Indicates the max dimension for images in rationale
145
+
146
+ # `maxImageHeight` (object)
147
+
148
+ Properties of the `maxImageHeight` object:
149
+
150
+ ## `teacherInstructions` (number)
151
+
152
+ Indicates the max dimension for images in teacher instructions
153
+
154
+ ## `prompt` (number)
155
+
156
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
157
+
158
+ ## `rationale` (number)
159
+
160
+ Indicates the max dimension for images in rationale
161
+
162
+ # `withRubric` (object)
163
+
164
+ Properties of the `withRubric` object:
165
+
166
+ ## `settings` (boolean)
167
+
168
+ Indicates if the item has to be displayed in the Settings Panel
169
+
170
+ ## `label` (string)
171
+
172
+ Indicates the label for the item that has to be displayed in the Settings Panel
173
+
82
174
  # `showPrompt` (boolean)
83
175
 
84
176
  Determines whether prompt field will be displayed or not
@@ -130,4 +222,20 @@ Indicates the label for the item that has to be displayed in the Settings Panel
130
222
  ### `enabled` (boolean)
131
223
 
132
224
  Indicates the value of the item if it affects config-ui
133
- (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
225
+ (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
226
+
227
+ ## `ConfigureMaxImageDimensionsProp` (object)
228
+
229
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
230
+
231
+ ### `teacherInstructions` (number)
232
+
233
+ Indicates the max dimension for images in teacher instructions
234
+
235
+ ### `prompt` (number)
236
+
237
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
238
+
239
+ ### `rationale` (number)
240
+
241
+ Indicates the max dimension for images in rationale
@@ -2,11 +2,14 @@ exports.model = (id, element) => ({
2
2
  id,
3
3
  element,
4
4
  customKeys: [
5
- "\\square"
5
+ '\\square'
6
6
  ],
7
7
  feedback: { type: 'default', default: 'this is default feedback' },
8
8
  prompt: 'This is the question prompt',
9
9
  promptEnabled: true,
10
10
  mathInput: true,
11
+ playersToolbarPosition: 'bottom',
11
12
  toolbarEditorPosition: 'bottom',
13
+ spellCheckEnabled: true,
14
+ rubricEnabled: false
12
15
  });
@@ -63,6 +63,18 @@
63
63
  "type": "boolean",
64
64
  "title": "mathInput"
65
65
  },
66
+ "spanishInput": {
67
+ "description": "Whether a control to allow insertion of spanish characters should be displayed",
68
+ "default": false,
69
+ "type": "boolean",
70
+ "title": "spanishInput"
71
+ },
72
+ "specialInput": {
73
+ "description": "Whether a control to allow insertion of special characters should be displayed",
74
+ "default": false,
75
+ "type": "boolean",
76
+ "title": "specialInput"
77
+ },
66
78
  "multiple": {
67
79
  "description": "Indicates if multiple parts are enabled",
68
80
  "type": "boolean",
@@ -98,6 +110,16 @@
98
110
  "type": "boolean",
99
111
  "title": "rationaleEnabled"
100
112
  },
113
+ "spellCheckEnabled": {
114
+ "description": "Indicates if spellcheck is enabled for the author. Default value is true",
115
+ "type": "boolean",
116
+ "title": "spellCheckEnabled"
117
+ },
118
+ "playerSpellCheckEnabled": {
119
+ "description": "Indicates if spellcheck is enabled for the player. Default value is true",
120
+ "type": "boolean",
121
+ "title": "playerSpellCheckEnabled"
122
+ },
101
123
  "studentInstructionsEnabled": {
102
124
  "description": "Indicates if Student Instructions are enabled",
103
125
  "type": "boolean",
@@ -116,6 +138,21 @@
116
138
  "type": "string",
117
139
  "title": "toolbarEditorPosition"
118
140
  },
141
+ "playersToolbarPosition": {
142
+ "description": "Indicates the editor's toolbar position for the player, which can be 'bottom' or 'top'",
143
+ "default": ": 'bottom'",
144
+ "enum": [
145
+ "bottom",
146
+ "top"
147
+ ],
148
+ "type": "string",
149
+ "title": "playersToolbarPosition"
150
+ },
151
+ "rubricEnabled": {
152
+ "description": "Indicates if Rubric is enabled",
153
+ "type": "boolean",
154
+ "title": "rubricEnabled"
155
+ },
119
156
  "id": {
120
157
  "description": "Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.",
121
158
  "type": "string",
@@ -132,7 +169,10 @@
132
169
  "element",
133
170
  "feedbackEnabled",
134
171
  "id",
172
+ "playerSpellCheckEnabled",
135
173
  "rationaleEnabled",
174
+ "rubricEnabled",
175
+ "spellCheckEnabled",
136
176
  "studentInstructionsEnabled",
137
177
  "teacherInstructionsEnabled"
138
178
  ],
@@ -174,6 +214,27 @@
174
214
  }
175
215
  }
176
216
  },
217
+ "ConfigureMaxImageDimensionsProp": {
218
+ "title": "ConfigureMaxImageDimensionsProp",
219
+ "type": "object",
220
+ "properties": {
221
+ "teacherInstructions": {
222
+ "description": "Indicates the max dimension for images in teacher instructions",
223
+ "type": "number",
224
+ "title": "teacherInstructions"
225
+ },
226
+ "prompt": {
227
+ "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",
228
+ "type": "number",
229
+ "title": "prompt"
230
+ },
231
+ "rationale": {
232
+ "description": "Indicates the max dimension for images in rationale",
233
+ "type": "number",
234
+ "title": "rationale"
235
+ }
236
+ }
237
+ },
177
238
  "Dimensions": {
178
239
  "title": "Dimensions",
179
240
  "type": "object",
@@ -52,6 +52,18 @@ Whether a control to allow insertion of math forumulas should be displayed
52
52
 
53
53
  Default: `false`
54
54
 
55
+ # `spanishInput` (boolean)
56
+
57
+ Whether a control to allow insertion of spanish characters should be displayed
58
+
59
+ Default: `false`
60
+
61
+ # `specialInput` (boolean)
62
+
63
+ Whether a control to allow insertion of special characters should be displayed
64
+
65
+ Default: `false`
66
+
55
67
  # `multiple` (boolean)
56
68
 
57
69
  Indicates if multiple parts are enabled
@@ -80,6 +92,14 @@ Indicates if Feedback is enabled
80
92
 
81
93
  Indicates if Rationale are enabled
82
94
 
95
+ # `spellCheckEnabled` (boolean, required)
96
+
97
+ Indicates if spellcheck is enabled for the author. Default value is true
98
+
99
+ # `playerSpellCheckEnabled` (boolean, required)
100
+
101
+ Indicates if spellcheck is enabled for the player. Default value is true
102
+
83
103
  # `studentInstructionsEnabled` (boolean, required)
84
104
 
85
105
  Indicates if Student Instructions are enabled
@@ -95,6 +115,21 @@ This element must be one of the following enum values:
95
115
  * `bottom`
96
116
  * `top`
97
117
 
118
+ # `playersToolbarPosition` (string, enum)
119
+
120
+ Indicates the editor's toolbar position for the player, which can be 'bottom' or 'top'
121
+
122
+ This element must be one of the following enum values:
123
+
124
+ * `bottom`
125
+ * `top`
126
+
127
+ Default: `": 'bottom'"`
128
+
129
+ # `rubricEnabled` (boolean, required)
130
+
131
+ Indicates if Rubric is enabled
132
+
98
133
  # `id` (string, required)
99
134
 
100
135
  Identifier to identify the Pie Element in html markup, Must be unique within a pie item config.
@@ -138,6 +173,22 @@ Indicates the label for the item that has to be displayed in the Settings Panel
138
173
  Indicates the value of the item if it affects config-ui
139
174
  (eg.: if item is a switch and displaying an input on the config-ui depends on the switch value: on/off)
140
175
 
176
+ ## `ConfigureMaxImageDimensionsProp` (object)
177
+
178
+ Properties of the `ConfigureMaxImageDimensionsProp` object:
179
+
180
+ ### `teacherInstructions` (number)
181
+
182
+ Indicates the max dimension for images in teacher instructions
183
+
184
+ ### `prompt` (number)
185
+
186
+ Indicates the max dimension for images in prompt - this is also the default dimension for all other input fields if it's not specified
187
+
188
+ ### `rationale` (number)
189
+
190
+ Indicates the max dimension for images in rationale
191
+
141
192
  ## `Dimensions` (object)
142
193
 
143
194
  Properties of the `Dimensions` object:
package/lib/index.js CHANGED
@@ -5,9 +5,9 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.textContent = textContent;
9
- exports.isComplete = isComplete;
10
8
  exports["default"] = void 0;
9
+ exports.isComplete = isComplete;
10
+ exports.textContent = textContent;
11
11
 
12
12
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
13
13
 
@@ -29,13 +29,15 @@ var _react = _interopRequireDefault(require("react"));
29
29
 
30
30
  var _reactDom = _interopRequireDefault(require("react-dom"));
31
31
 
32
+ var _mathRendering = require("@pie-lib/math-rendering");
33
+
32
34
  var _piePlayerEvents = require("@pie-framework/pie-player-events");
33
35
 
34
36
  var _debug = _interopRequireDefault(require("debug"));
35
37
 
36
38
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
37
39
 
38
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
40
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
39
41
 
40
42
  var log = (0, _debug["default"])('@pie-ui:extended-text-entry');
41
43
  var domParser = (typeof window === "undefined" ? "undefined" : (0, _typeof2["default"])(window)) !== undefined ? new DOMParser() : {
@@ -89,6 +91,9 @@ var RootExtendedTextEntry = /*#__PURE__*/function (_HTMLElement) {
89
91
  }
90
92
  }, {
91
93
  key: "session",
94
+ get: function get() {
95
+ return this._session;
96
+ },
92
97
  set: function set(s) {
93
98
  this._session = s;
94
99
  this.render();
@@ -107,6 +112,8 @@ var RootExtendedTextEntry = /*#__PURE__*/function (_HTMLElement) {
107
112
  }, {
108
113
  key: "render",
109
114
  value: function render() {
115
+ var _this2 = this;
116
+
110
117
  if (this._model && this._session) {
111
118
  var elem = /*#__PURE__*/_react["default"].createElement(_main["default"], {
112
119
  model: this._model,
@@ -114,7 +121,9 @@ var RootExtendedTextEntry = /*#__PURE__*/function (_HTMLElement) {
114
121
  onChange: this.handleChange.bind(this)
115
122
  });
116
123
 
117
- _reactDom["default"].render(elem, this);
124
+ _reactDom["default"].render(elem, this, function () {
125
+ (0, _mathRendering.renderMath)(_this2);
126
+ });
118
127
  }
119
128
  }
120
129
  }]);
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","domParser","window","undefined","DOMParser","parseFromString","v","textContent","value","document","body","err","isComplete","tc","out","length","RootExtendedTextEntry","_model","_session","m","dispatchEvent","ModelSetEvent","tagName","toLowerCase","render","s","SessionChangedEvent","elem","React","createElement","Main","model","session","onChange","handleChange","bind","ReactDOM","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAIA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,6BAAN,CAAZ;AAEA,IAAMC,SAAS,GACb,QAAOC,MAAP,0DAAOA,MAAP,OAAkBC,SAAlB,GAA8B,IAAIC,SAAJ,EAA9B,GAAgD;AAAEC,EAAAA,eAAe,EAAE,yBAAAC,CAAC;AAAA,WAAIA,CAAJ;AAAA;AAApB,CADlD;;AAGO,SAASC,WAAT,CAAqBC,KAArB,EAA4B;AACjC,MAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC7B,WAAOL,SAAP;AACD;;AACD,MAAI;AACF,QAAMM,QAAQ,GAAGR,SAAS,CAACI,eAAV,CAA0BG,KAA1B,EAAiC,WAAjC,CAAjB;AACA,QAAMD,YAAW,GAAGE,QAAQ,CAACC,IAAT,CAAcH,WAAlC;AACA,WAAOA,YAAP;AACD,GAJD,CAIE,OAAOI,GAAP,EAAY;AACZX,IAAAA,GAAG,CAAC,kCAAD,EAAqCQ,KAArC,CAAH;AACA,WAAOA,KAAP;AACD;AACF;;AAEM,SAASI,UAAT,CAAoBJ,KAApB,EAA2B;AAChC,MAAMK,EAAE,GAAGN,WAAW,CAACC,KAAD,CAAtB;AACA,MAAMM,GAAG,GAAGD,EAAE,KAAKV,SAAP,IAAoBU,EAAE,CAACE,MAAH,GAAY,CAA5C;AACA,SAAOD,GAAP;AACD;;IAEoBE,qB;;;;;AACnB,mCAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAHY;AAIb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKF,MAAL,GAAcE,CAAd;AACA,WAAKC,aAAL,CACE,IAAIC,8BAAJ,CAAkB,KAAKC,OAAL,CAAaC,WAAb,EAAlB,EAA8C,KAA9C,EAAqD,CAAC,CAAC,KAAKN,MAA5D,CADF;AAIA,WAAKO,MAAL;AACD;;;SAED,aAAYC,CAAZ,EAAe;AACb,WAAKP,QAAL,GAAgBO,CAAhB;AACA,WAAKD,MAAL;AACD;;;WAED,sBAAahB,KAAb,EAAoB;AAClB,WAAKU,QAAL,CAAcV,KAAd,GAAsBA,KAAtB;AAEA,WAAKY,aAAL,CACE,IAAIM,oCAAJ,CAAwB,KAAKJ,OAAL,CAAaC,WAAb,EAAxB,EAAoDX,UAAU,CAACJ,KAAD,CAA9D,CADF;AAGD;;;WAED,6BAAoB;AAClB,WAAKgB,MAAL;AACD;;;WAED,kBAAS;AACP,UAAI,KAAKP,MAAL,IAAe,KAAKC,QAAxB,EAAkC;AAChC,YAAIS,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA,KAAK,EAAE,KAAKd,MADuB;AAEnCe,UAAAA,OAAO,EAAE,KAAKd,QAFqB;AAGnCe,UAAAA,QAAQ,EAAE,KAAKC,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB;AAHyB,SAA1B,CAAX;;AAKAC,6BAASZ,MAAT,CAAgBG,IAAhB,EAAsB,IAAtB;AACD;AACF;;;kDA1CgDU,W","sourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport {\n ModelSetEvent,\n SessionChangedEvent\n} from '@pie-framework/pie-player-events';\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:extended-text-entry');\n\nconst domParser =\n typeof window !== undefined ? new DOMParser() : { parseFromString: v => v };\n\nexport function textContent(value) {\n if (typeof value !== 'string') {\n return undefined;\n }\n try {\n const document = domParser.parseFromString(value, 'text/html');\n const textContent = document.body.textContent;\n return textContent;\n } catch (err) {\n log('tried to parse as dom and failed', value);\n return value;\n }\n}\n\nexport function isComplete(value) {\n const tc = textContent(value);\n const out = tc !== undefined && tc.length > 0;\n return out;\n}\n\nexport default class RootExtendedTextEntry extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(this.tagName.toLowerCase(), false, !!this._model)\n );\n\n this.render();\n }\n\n set session(s) {\n this._session = s;\n this.render();\n }\n\n handleChange(value) {\n this._session.value = value;\n\n this.dispatchEvent(\n new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(value))\n );\n }\n\n connectedCallback() {\n this.render();\n }\n\n render() {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onChange: this.handleChange.bind(this)\n });\n ReactDOM.render(elem, this);\n }\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","domParser","window","undefined","DOMParser","parseFromString","v","textContent","value","document","body","err","isComplete","tc","out","length","RootExtendedTextEntry","_model","_session","m","dispatchEvent","ModelSetEvent","tagName","toLowerCase","render","s","SessionChangedEvent","elem","React","createElement","Main","model","session","onChange","handleChange","bind","ReactDOM","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AAIA;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,6BAAN,CAAZ;AAEA,IAAMC,SAAS,GACb,QAAOC,MAAP,0DAAOA,MAAP,OAAkBC,SAAlB,GAA8B,IAAIC,SAAJ,EAA9B,GAAgD;AAAEC,EAAAA,eAAe,EAAE,yBAAAC,CAAC;AAAA,WAAIA,CAAJ;AAAA;AAApB,CADlD;;AAGO,SAASC,WAAT,CAAqBC,KAArB,EAA4B;AACjC,MAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC7B,WAAOL,SAAP;AACD;;AACD,MAAI;AACF,QAAMM,QAAQ,GAAGR,SAAS,CAACI,eAAV,CAA0BG,KAA1B,EAAiC,WAAjC,CAAjB;AACA,QAAMD,YAAW,GAAGE,QAAQ,CAACC,IAAT,CAAcH,WAAlC;AACA,WAAOA,YAAP;AACD,GAJD,CAIE,OAAOI,GAAP,EAAY;AACZX,IAAAA,GAAG,CAAC,kCAAD,EAAqCQ,KAArC,CAAH;AACA,WAAOA,KAAP;AACD;AACF;;AAEM,SAASI,UAAT,CAAoBJ,KAApB,EAA2B;AAChC,MAAMK,EAAE,GAAGN,WAAW,CAACC,KAAD,CAAtB;AACA,MAAMM,GAAG,GAAGD,EAAE,KAAKV,SAAP,IAAoBU,EAAE,CAACE,MAAH,GAAY,CAA5C;AACA,SAAOD,GAAP;AACD;;IAEoBE,qB;;;;;AACnB,mCAAc;AAAA;;AAAA;AACZ;AACA,UAAKC,MAAL,GAAc,IAAd;AACA,UAAKC,QAAL,GAAgB,IAAhB;AAHY;AAIb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKF,MAAL,GAAcE,CAAd;AACA,WAAKC,aAAL,CACE,IAAIC,8BAAJ,CAAkB,KAAKC,OAAL,CAAaC,WAAb,EAAlB,EAA8C,KAA9C,EAAqD,CAAC,CAAC,KAAKN,MAA5D,CADF;AAIA,WAAKO,MAAL;AACD;;;SAOD,eAAc;AACZ,aAAO,KAAKN,QAAZ;AACD,K;SAPD,aAAYO,CAAZ,EAAe;AACb,WAAKP,QAAL,GAAgBO,CAAhB;AACA,WAAKD,MAAL;AACD;;;WAMD,sBAAahB,KAAb,EAAoB;AAClB,WAAKU,QAAL,CAAcV,KAAd,GAAsBA,KAAtB;AAEA,WAAKY,aAAL,CACE,IAAIM,oCAAJ,CAAwB,KAAKJ,OAAL,CAAaC,WAAb,EAAxB,EAAoDX,UAAU,CAACJ,KAAD,CAA9D,CADF;AAGD;;;WAED,6BAAoB;AAClB,WAAKgB,MAAL;AACD;;;WAED,kBAAS;AAAA;;AACP,UAAI,KAAKP,MAAL,IAAe,KAAKC,QAAxB,EAAkC;AAChC,YAAIS,IAAI,gBAAGC,kBAAMC,aAAN,CAAoBC,gBAApB,EAA0B;AACnCC,UAAAA,KAAK,EAAE,KAAKd,MADuB;AAEnCe,UAAAA,OAAO,EAAE,KAAKd,QAFqB;AAGnCe,UAAAA,QAAQ,EAAE,KAAKC,YAAL,CAAkBC,IAAlB,CAAuB,IAAvB;AAHyB,SAA1B,CAAX;;AAMAC,6BAASZ,MAAT,CAAgBG,IAAhB,EAAsB,IAAtB,EAA4B,YAAM;AAChC,yCAAW,MAAX;AACD,SAFD;AAGD;AACF;;;kDAjDgDU,W","sourcesContent":["import Main from './main';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport {\n ModelSetEvent,\n SessionChangedEvent\n} from '@pie-framework/pie-player-events';\nimport debug from 'debug';\n\nconst log = debug('@pie-ui:extended-text-entry');\n\nconst domParser =\n typeof window !== undefined ? new DOMParser() : { parseFromString: v => v };\n\nexport function textContent(value) {\n if (typeof value !== 'string') {\n return undefined;\n }\n try {\n const document = domParser.parseFromString(value, 'text/html');\n const textContent = document.body.textContent;\n return textContent;\n } catch (err) {\n log('tried to parse as dom and failed', value);\n return value;\n }\n}\n\nexport function isComplete(value) {\n const tc = textContent(value);\n const out = tc !== undefined && tc.length > 0;\n return out;\n}\n\nexport default class RootExtendedTextEntry extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(\n new ModelSetEvent(this.tagName.toLowerCase(), false, !!this._model)\n );\n\n this.render();\n }\n\n set session(s) {\n this._session = s;\n this.render();\n }\n\n get session() {\n return this._session;\n }\n\n handleChange(value) {\n this._session.value = value;\n\n this.dispatchEvent(\n new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(value))\n );\n }\n\n connectedCallback() {\n this.render();\n }\n\n render() {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onChange: this.handleChange.bind(this)\n });\n\n ReactDOM.render(elem, this, () => {\n renderMath(this);\n });\n }\n }\n}\n"],"file":"index.js"}