@pie-lib/editable-html 11.1.1 → 11.2.0-beta.1
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/CHANGELOG.md +43 -167
- package/NEXT.CHANGELOG.json +1 -0
- package/lib/block-tags.js +25 -0
- package/lib/block-tags.js.map +1 -0
- package/lib/constants.js +16 -0
- package/lib/constants.js.map +1 -0
- package/lib/editor.js +348 -87
- package/lib/editor.js.map +1 -1
- package/lib/index.js +25 -9
- package/lib/index.js.map +1 -1
- package/lib/plugins/characters/index.js +8 -3
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/characters/utils.js +12 -12
- package/lib/plugins/characters/utils.js.map +1 -1
- package/lib/plugins/css/icons/index.js +37 -0
- package/lib/plugins/css/icons/index.js.map +1 -0
- package/lib/plugins/css/index.js +397 -0
- package/lib/plugins/css/index.js.map +1 -0
- package/lib/plugins/customPlugin/index.js +114 -0
- package/lib/plugins/customPlugin/index.js.map +1 -0
- package/lib/plugins/html/index.js +11 -7
- package/lib/plugins/html/index.js.map +1 -1
- package/lib/plugins/image/index.js +2 -1
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +13 -4
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +270 -11
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +130 -0
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +91 -56
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +5 -2
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +98 -57
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/rendering/index.js +46 -0
- package/lib/plugins/rendering/index.js.map +1 -0
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +5 -2
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +11 -9
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +69 -21
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +10 -5
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/math-templated/index.js +130 -0
- package/lib/plugins/respArea/math-templated/index.js.map +1 -0
- package/lib/plugins/respArea/utils.js +16 -1
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/CustomTablePlugin.js +133 -0
- package/lib/plugins/table/CustomTablePlugin.js.map +1 -0
- package/lib/plugins/table/index.js +43 -59
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +33 -4
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/textAlign/icons/index.js +226 -0
- package/lib/plugins/textAlign/icons/index.js.map +1 -0
- package/lib/plugins/textAlign/index.js +34 -0
- package/lib/plugins/textAlign/index.js.map +1 -0
- package/lib/plugins/toolbar/default-toolbar.js +82 -27
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +5 -2
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +18 -19
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +44 -11
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +35 -11
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/serialization.js +233 -44
- package/lib/serialization.js.map +1 -1
- package/package.json +11 -6
- package/src/__tests__/editor.test.jsx +363 -0
- package/src/__tests__/serialization.test.js +291 -0
- package/src/__tests__/utils.js +36 -0
- package/src/block-tags.js +17 -0
- package/src/constants.js +7 -0
- package/src/editor.jsx +303 -49
- package/src/index.jsx +19 -10
- package/src/plugins/characters/index.jsx +11 -3
- package/src/plugins/characters/utils.js +12 -12
- package/src/plugins/css/icons/index.jsx +17 -0
- package/src/plugins/css/index.jsx +346 -0
- package/src/plugins/customPlugin/index.jsx +85 -0
- package/src/plugins/html/index.jsx +9 -6
- package/src/plugins/image/__tests__/__snapshots__/component.test.jsx.snap +51 -0
- package/src/plugins/image/__tests__/__snapshots__/image-toolbar-logic.test.jsx.snap +27 -0
- package/src/plugins/image/__tests__/__snapshots__/image-toolbar.test.jsx.snap +44 -0
- package/src/plugins/image/__tests__/component.test.jsx +41 -0
- package/src/plugins/image/__tests__/image-toolbar-logic.test.jsx +42 -0
- package/src/plugins/image/__tests__/image-toolbar.test.jsx +11 -0
- package/src/plugins/image/__tests__/index.test.js +95 -0
- package/src/plugins/image/__tests__/insert-image-handler.test.js +113 -0
- package/src/plugins/image/__tests__/mock-change.js +15 -0
- package/src/plugins/image/index.jsx +2 -1
- package/src/plugins/image/insert-image-handler.js +13 -6
- package/src/plugins/index.jsx +248 -5
- package/src/plugins/list/__tests__/index.test.js +54 -0
- package/src/plugins/list/index.jsx +130 -0
- package/src/plugins/math/__tests__/__snapshots__/index.test.jsx.snap +48 -0
- package/src/plugins/math/__tests__/index.test.jsx +245 -0
- package/src/plugins/math/index.jsx +87 -56
- package/src/plugins/media/__tests__/index.test.js +75 -0
- package/src/plugins/media/index.jsx +3 -2
- package/src/plugins/media/media-dialog.js +106 -57
- package/src/plugins/rendering/index.js +31 -0
- package/src/plugins/respArea/drag-in-the-blank/choice.jsx +4 -1
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +10 -8
- package/src/plugins/respArea/index.jsx +53 -7
- package/src/plugins/respArea/inline-dropdown/index.jsx +13 -6
- package/src/plugins/respArea/math-templated/index.jsx +104 -0
- package/src/plugins/respArea/utils.jsx +11 -0
- package/src/plugins/table/CustomTablePlugin.js +113 -0
- package/src/plugins/table/__tests__/__snapshots__/table-toolbar.test.jsx.snap +44 -0
- package/src/plugins/table/__tests__/index.test.jsx +401 -0
- package/src/plugins/table/__tests__/table-toolbar.test.jsx +42 -0
- package/src/plugins/table/index.jsx +46 -59
- package/src/plugins/table/table-toolbar.jsx +39 -2
- package/src/plugins/textAlign/icons/index.jsx +139 -0
- package/src/plugins/textAlign/index.jsx +23 -0
- package/src/plugins/toolbar/__tests__/__snapshots__/default-toolbar.test.jsx.snap +923 -0
- package/src/plugins/toolbar/__tests__/__snapshots__/editor-and-toolbar.test.jsx.snap +20 -0
- package/src/plugins/toolbar/__tests__/__snapshots__/toolbar-buttons.test.jsx.snap +36 -0
- package/src/plugins/toolbar/__tests__/__snapshots__/toolbar.test.jsx.snap +46 -0
- package/src/plugins/toolbar/__tests__/default-toolbar.test.jsx +94 -0
- package/src/plugins/toolbar/__tests__/editor-and-toolbar.test.jsx +37 -0
- package/src/plugins/toolbar/__tests__/toolbar-buttons.test.jsx +51 -0
- package/src/plugins/toolbar/__tests__/toolbar.test.jsx +106 -0
- package/src/plugins/toolbar/default-toolbar.jsx +82 -20
- package/src/plugins/toolbar/done-button.jsx +3 -1
- package/src/plugins/toolbar/editor-and-toolbar.jsx +18 -13
- package/src/plugins/toolbar/toolbar-buttons.jsx +52 -11
- package/src/plugins/toolbar/toolbar.jsx +31 -8
- package/src/serialization.jsx +213 -38
- package/README.md +0 -45
- package/deploy.sh +0 -16
- package/playground/image/data.js +0 -59
- package/playground/image/index.html +0 -22
- package/playground/image/index.jsx +0 -81
- package/playground/index.html +0 -25
- package/playground/mathquill/index.html +0 -22
- package/playground/mathquill/index.jsx +0 -155
- package/playground/package.json +0 -15
- package/playground/prod-test/index.html +0 -22
- package/playground/prod-test/index.jsx +0 -28
- package/playground/schema-override/data.js +0 -29
- package/playground/schema-override/image-plugin.jsx +0 -41
- package/playground/schema-override/index.html +0 -21
- package/playground/schema-override/index.jsx +0 -97
- package/playground/serialization/data.js +0 -29
- package/playground/serialization/image-plugin.jsx +0 -41
- package/playground/serialization/index.html +0 -22
- package/playground/serialization/index.jsx +0 -12
- package/playground/static.json +0 -3
- package/playground/table-examples.html +0 -70
- package/playground/webpack.config.js +0 -42
- package/static.json +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/respArea/explicit-constructed-response/index.jsx"],"names":["ExplicitConstructedResponse","props","attributes","value","error","display","minHeight","minWidth","position","
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/respArea/explicit-constructed-response/index.jsx"],"names":["ExplicitConstructedResponse","props","attributes","value","error","display","visibility","isFocused","minHeight","minWidth","position","cursor","width","height","backgroundColor","border","boxSizing","borderRadius","overflow","padding","marginLeft","__html","propTypes","PropTypes","object","any","string","bool"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA8B,CAACC,KAAD,EAAW;AAC7C,MAAQC,UAAR,GAAqCD,KAArC,CAAQC,UAAR;AAAA,MAAoBC,KAApB,GAAqCF,KAArC,CAAoBE,KAApB;AAAA,MAA2BC,KAA3B,GAAqCH,KAArC,CAA2BG,KAA3B;AAEA,sBACE,sEACMF,UADN;AAEE,IAAA,KAAK,EAAE;AACLG,MAAAA,OAAO,EAAE,aADJ;AAELC,MAAAA,UAAU,EAAEL,KAAK,CAACM,SAAN,GAAkB,QAAlB,GAA6B,SAFpC;AAGLC,MAAAA,SAAS,EAAE,MAHN;AAILC,MAAAA,QAAQ,EAAE,OAJL;AAKLC,MAAAA,QAAQ,EAAE,UALL;AAMLC,MAAAA,MAAM,EAAE;AANH;AAFT,mBAWE;AACE,IAAA,KAAK,EAAE;AACLN,MAAAA,OAAO,EAAE,aADJ;AAELO,MAAAA,KAAK,EAAE,MAFF;AAGLJ,MAAAA,SAAS,EAAE,MAHN;AAILK,MAAAA,MAAM,EAAE,MAJH;AAKLC,MAAAA,eAAe,EAAE,MALZ;AAMLC,MAAAA,MAAM,sBAAeX,KAAK,GAAG,KAAH,GAAW,SAA/B,CAND;AAOLY,MAAAA,SAAS,EAAE,YAPN;AAQLC,MAAAA,YAAY,EAAE,KART;AASLC,MAAAA,QAAQ,EAAE,QATL;AAULC,MAAAA,OAAO,EAAE,WAVJ;AAWLC,MAAAA,UAAU,EAAE;AAXP,KADT;AAcE,IAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM,EAAElB,KAAK,IAAI;AADM;AAd3B,IAXF,CADF;AAgCD,CAnCD;;AAqCAH,2BAA2B,CAACsB,SAA5B,GAAwC;AACtCpB,EAAAA,UAAU,EAAEqB,sBAAUC,MADgB;AAEtCpB,EAAAA,KAAK,EAAEmB,sBAAUE,GAFqB;AAGtCtB,EAAAA,KAAK,EAAEoB,sBAAUG,MAHqB;AAItCnB,EAAAA,SAAS,EAAEgB,sBAAUI;AAJiB,CAAxC;eAOe3B,2B","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst ExplicitConstructedResponse = (props) => {\n const { attributes, value, error } = props;\n\n return (\n <span\n {...attributes}\n style={{\n display: 'inline-flex',\n visibility: props.isFocused ? 'hidden' : 'visible',\n minHeight: '55px',\n minWidth: '178px',\n position: 'relative',\n cursor: 'pointer',\n }}\n >\n <div\n style={{\n display: 'inline-flex',\n width: '100%',\n minHeight: '46px',\n height: '46px',\n backgroundColor: '#FFF',\n border: `1px solid ${error ? 'red' : '#C0C3CF'}`,\n boxSizing: 'border-box',\n borderRadius: '4px',\n overflow: 'hidden',\n padding: '12px 21px',\n marginLeft: '4px',\n }}\n dangerouslySetInnerHTML={{\n __html: value || '<div> </div>',\n }}\n />\n </span>\n );\n};\n\nExplicitConstructedResponse.propTypes = {\n attributes: PropTypes.object,\n error: PropTypes.any,\n value: PropTypes.string,\n isFocused: PropTypes.bool,\n};\n\nexport default ExplicitConstructedResponse;\n"],"file":"index.js"}
|
|
@@ -20,6 +20,8 @@ var _dragInTheBlank = _interopRequireDefault(require("./drag-in-the-blank"));
|
|
|
20
20
|
|
|
21
21
|
var _explicitConstructedResponse = _interopRequireDefault(require("./explicit-constructed-response"));
|
|
22
22
|
|
|
23
|
+
var _mathTemplated = _interopRequireDefault(require("./math-templated"));
|
|
24
|
+
|
|
23
25
|
var _utils = require("./utils");
|
|
24
26
|
|
|
25
27
|
var _icons = require("./icons");
|
|
@@ -29,6 +31,7 @@ var lastIndexMap = {};
|
|
|
29
31
|
var elTypesMap = {
|
|
30
32
|
'inline-dropdown': 'inline_dropdown',
|
|
31
33
|
'explicit-constructed-response': 'explicit_constructed_response',
|
|
34
|
+
'math-templated': 'math_templated',
|
|
32
35
|
'drag-in-the-blank': 'drag_in_the_blank'
|
|
33
36
|
};
|
|
34
37
|
var elTypesArray = Object.values(elTypesMap);
|
|
@@ -86,6 +89,14 @@ function ResponseAreaPlugin(opts) {
|
|
|
86
89
|
}
|
|
87
90
|
}
|
|
88
91
|
|
|
92
|
+
if (newInline.type === 'math_templated') {
|
|
93
|
+
var _nextText = change.value.document.getNextText(newInline.key);
|
|
94
|
+
|
|
95
|
+
if (_nextText) {
|
|
96
|
+
change.moveFocusTo(_nextText.key, 0).moveAnchorTo(_nextText.key, 0);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
89
100
|
onChange(change);
|
|
90
101
|
}
|
|
91
102
|
},
|
|
@@ -99,7 +110,7 @@ function ResponseAreaPlugin(opts) {
|
|
|
99
110
|
name: 'response_area',
|
|
100
111
|
toolbar: toolbar,
|
|
101
112
|
filterPlugins: function filterPlugins(node, plugins) {
|
|
102
|
-
if (node.type === 'explicit_constructed_response' || node.type === 'drag_in_the_blank') {
|
|
113
|
+
if (node.type === 'explicit_constructed_response' || node.type === 'math_templated' || node.type === 'drag_in_the_blank') {
|
|
103
114
|
return [];
|
|
104
115
|
}
|
|
105
116
|
|
|
@@ -114,7 +125,8 @@ function ResponseAreaPlugin(opts) {
|
|
|
114
125
|
},
|
|
115
126
|
renderNode: function renderNode(props) {
|
|
116
127
|
var attributes = props.attributes,
|
|
117
|
-
n = props.node
|
|
128
|
+
n = props.node,
|
|
129
|
+
isFocused = props.isFocused;
|
|
118
130
|
|
|
119
131
|
if (n.type === 'explicit_constructed_response') {
|
|
120
132
|
var data = n.data.toJSON();
|
|
@@ -126,17 +138,37 @@ function ResponseAreaPlugin(opts) {
|
|
|
126
138
|
|
|
127
139
|
return /*#__PURE__*/_react["default"].createElement(_explicitConstructedResponse["default"], {
|
|
128
140
|
attributes: attributes,
|
|
141
|
+
isFocused: isFocused,
|
|
129
142
|
value: data.value,
|
|
130
143
|
error: error && error[data.index] && error[data.index][0]
|
|
131
144
|
});
|
|
132
145
|
}
|
|
133
146
|
|
|
134
|
-
if (n.type === '
|
|
147
|
+
if (n.type === 'math_templated') {
|
|
135
148
|
var _data = n.data.toJSON();
|
|
136
149
|
|
|
150
|
+
var _error;
|
|
151
|
+
|
|
152
|
+
if (opts.error) {
|
|
153
|
+
_error = opts.error();
|
|
154
|
+
} // add 1 to index to display R 1 instead of R 0
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
var keyToDisplay = "R ".concat(parseInt(_data.index) + 1);
|
|
158
|
+
return /*#__PURE__*/_react["default"].createElement(_mathTemplated["default"], {
|
|
159
|
+
attributes: attributes,
|
|
160
|
+
keyToDisplay: keyToDisplay,
|
|
161
|
+
value: _data.value || '',
|
|
162
|
+
error: _error && _error[_data.index] && _error[_data.index][0]
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (n.type === 'drag_in_the_blank') {
|
|
167
|
+
var _data2 = n.data.toJSON();
|
|
168
|
+
|
|
137
169
|
return /*#__PURE__*/_react["default"].createElement(_dragInTheBlank["default"], {
|
|
138
170
|
attributes: attributes,
|
|
139
|
-
data:
|
|
171
|
+
data: _data2,
|
|
140
172
|
n: n,
|
|
141
173
|
nodeProps: props,
|
|
142
174
|
opts: opts
|
|
@@ -144,11 +176,11 @@ function ResponseAreaPlugin(opts) {
|
|
|
144
176
|
}
|
|
145
177
|
|
|
146
178
|
if (n.type === 'inline_dropdown') {
|
|
147
|
-
var
|
|
179
|
+
var _data3 = n.data.toJSON();
|
|
148
180
|
|
|
149
181
|
return /*#__PURE__*/_react["default"].createElement(_inlineDropdown["default"], {
|
|
150
182
|
attributes: attributes,
|
|
151
|
-
selectedItem:
|
|
183
|
+
selectedItem: _data3.value
|
|
152
184
|
});
|
|
153
185
|
}
|
|
154
186
|
},
|
|
@@ -174,13 +206,7 @@ function ResponseAreaPlugin(opts) {
|
|
|
174
206
|
|
|
175
207
|
var currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);
|
|
176
208
|
var oldRespAreaList = editor.value.document.filterDescendants(isOfCurrentType);
|
|
177
|
-
|
|
178
|
-
if (currentRespAreaList.size >= opts.maxResponseAreas) {
|
|
179
|
-
toolbar.disabled = true;
|
|
180
|
-
} else {
|
|
181
|
-
toolbar.disabled = false;
|
|
182
|
-
}
|
|
183
|
-
|
|
209
|
+
toolbar.disabled = currentRespAreaList.size >= opts.maxResponseAreas;
|
|
184
210
|
var arrayToFilter = oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;
|
|
185
211
|
var arrayToUseForFilter = arrayToFilter === oldRespAreaList ? currentRespAreaList : oldRespAreaList;
|
|
186
212
|
var elementsWithChangedStatus = arrayToFilter.filter(function (d) {
|
|
@@ -233,6 +259,17 @@ var serialization = {
|
|
|
233
259
|
}
|
|
234
260
|
};
|
|
235
261
|
|
|
262
|
+
case 'math_templated':
|
|
263
|
+
return {
|
|
264
|
+
object: 'inline',
|
|
265
|
+
type: 'math_templated',
|
|
266
|
+
isVoid: true,
|
|
267
|
+
data: {
|
|
268
|
+
index: el.dataset.index,
|
|
269
|
+
value: el.dataset.value
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
|
|
236
273
|
case 'drag_in_the_blank':
|
|
237
274
|
return {
|
|
238
275
|
object: 'inline',
|
|
@@ -265,25 +302,36 @@ var serialization = {
|
|
|
265
302
|
|
|
266
303
|
case 'explicit_constructed_response':
|
|
267
304
|
{
|
|
268
|
-
var
|
|
305
|
+
var _data4 = object.data.toJSON();
|
|
269
306
|
|
|
270
307
|
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
271
308
|
"data-type": "explicit_constructed_response",
|
|
272
|
-
"data-index":
|
|
273
|
-
"data-value":
|
|
309
|
+
"data-index": _data4.index,
|
|
310
|
+
"data-value": _data4.value
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
case 'math_templated':
|
|
315
|
+
{
|
|
316
|
+
var _data5 = object.data.toJSON();
|
|
317
|
+
|
|
318
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
319
|
+
"data-type": "math_templated",
|
|
320
|
+
"data-index": _data5.index,
|
|
321
|
+
"data-value": _data5.value
|
|
274
322
|
});
|
|
275
323
|
}
|
|
276
324
|
|
|
277
325
|
case 'drag_in_the_blank':
|
|
278
326
|
{
|
|
279
|
-
var
|
|
327
|
+
var _data6 = object.data.toJSON();
|
|
280
328
|
|
|
281
329
|
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
282
330
|
"data-type": "drag_in_the_blank",
|
|
283
|
-
"data-index":
|
|
284
|
-
"data-id":
|
|
285
|
-
"data-value":
|
|
286
|
-
"data-in-table":
|
|
331
|
+
"data-index": _data6.index,
|
|
332
|
+
"data-id": _data6.id,
|
|
333
|
+
"data-value": _data6.value,
|
|
334
|
+
"data-in-table": _data6.inTable
|
|
287
335
|
});
|
|
288
336
|
}
|
|
289
337
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/respArea/index.jsx"],"names":["log","lastIndexMap","elTypesMap","elTypesArray","Object","values","ResponseAreaPlugin","opts","isOfCurrentType","d","type","toolbar","icon","buttonStyles","margin","onClick","value","onChange","change","currentRespAreaList","document","filterDescendants","size","maxResponseAreas","replace","prevIndex","newIndex","newInline","selection","startKey","endKey","insertInline","lastText","getLastText","parentNode","getParent","key","index","nodes","indexOf","isVoid","insertNodeByKey","nextText","getNextText","moveFocusTo","moveAnchorTo","customToolbar","respAreaToolbar","supports","node","object","showDone","name","filterPlugins","plugins","filter","p","deleteNode","e","preventDefault","removeNodeByKey","renderNode","props","attributes","n","data","toJSON","error","editor","forEachDescendant","parseInt","get","oldRespAreaList","disabled","arrayToFilter","arrayToUseForFilter","elementsWithChangedStatus","find","onHandleAreaChange","onDrop","event","closestEl","target","closest","inline","findDescendant","dataset","serialization","deserialize","el","id","inTable","serialize"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,GAAG,GAAG,uBAAM,yCAAN,CAAZ;AAEA,IAAMC,YAAY,GAAG,EAArB;AACA,IAAMC,UAAU,GAAG;AACjB,qBAAmB,iBADF;AAEjB,mCAAiC,+BAFhB;AAGjB,uBAAqB;AAHJ,CAAnB;AAKA,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcH,UAAd,CAArB;;AAEe,SAASI,kBAAT,CAA4BC,IAA5B,EAAkC;AAC/C,MAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAACC,CAAD;AAAA,WAAOA,CAAC,CAACC,IAAF,KAAWH,IAAI,CAACG,IAAhB,IAAwBD,CAAC,CAACC,IAAF,KAAWR,UAAU,CAACK,IAAI,CAACG,IAAN,CAApD;AAAA,GAAxB;;AAEA,MAAMC,OAAO,GAAG;AACdC,IAAAA,IAAI,eAAE,gCAAC,kBAAD,OADQ;AAEdC,IAAAA,YAAY,EAAE;AACZC,MAAAA,MAAM,EAAE;AADI,KAFA;AAKdC,IAAAA,OAAO,EAAE,iBAACC,KAAD,EAAQC,QAAR,EAAqB;AAC5BjB,MAAAA,GAAG,CAAC,mBAAD,CAAH;AACA,UAAMkB,MAAM,GAAGF,KAAK,CAACE,MAAN,EAAf;AACA,UAAMC,mBAAmB,GAAGD,MAAM,CAACF,KAAP,CAAaI,QAAb,CAAsBC,iBAAtB,CAAwCb,eAAxC,CAA5B;;AAEA,UAAIW,mBAAmB,CAACG,IAApB,IAA4Bf,IAAI,CAACgB,g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D,0BAAY4B,IAAI,CAACjD;AAA3E,YAAP;AACD;;AACD,WAAK,+BAAL;AAAsC;AACpC,cAAMiD,MAAI,GAAGf,MAAM,CAACe,IAAP,CAAYC,MAAZ,EAAb;;AAEA,8BAAO;AAAM,yBAAU,+BAAhB;AAAgD,0BAAYD,MAAI,CAAC5B,KAAjE;AAAwE,0BAAY4B,MAAI,CAACjD;AAAzF,YAAP;AACD;;AACD,WAAK,mBAAL;AAA0B;AACxB,cAAMiD,MAAI,GAAGf,MAAM,CAACe,IAAP,CAAYC,MAAZ,EAAb;;AAEA,8BACE;AACE,yBAAU,mBADZ;AAEE,0BAAYD,MAAI,CAAC5B,KAFnB;AAGE,uBAAS4B,MAAI,CAACyB,EAHhB;AAIE,0BAAYzB,MAAI,CAACjD,KAJnB;AAKE,6BAAeiD,MAAI,CAAC0B;AALtB,YADF;AASD;AAvBH;AAyBD;AArE0B,CAAtB","sourcesContent":["import React from 'react';\nimport debug from 'debug';\nimport isUndefined from 'lodash/isUndefined';\n\nimport InlineDropdown from './inline-dropdown';\nimport DragInTheBlank from './drag-in-the-blank';\nimport ExplicitConstructedResponse from './explicit-constructed-response';\nimport { getDefaultElement } from './utils';\nimport { ToolbarIcon } from './icons';\n\nconst log = debug('@pie-lib:editable-html:plugins:respArea');\n\nconst lastIndexMap = {};\nconst elTypesMap = {\n 'inline-dropdown': 'inline_dropdown',\n 'explicit-constructed-response': 'explicit_constructed_response',\n 'drag-in-the-blank': 'drag_in_the_blank',\n};\nconst elTypesArray = Object.values(elTypesMap);\n\nexport default function ResponseAreaPlugin(opts) {\n const isOfCurrentType = (d) => d.type === opts.type || d.type === elTypesMap[opts.type];\n\n const toolbar = {\n icon: <ToolbarIcon />,\n buttonStyles: {\n margin: '0 20px 0 auto',\n },\n onClick: (value, onChange) => {\n log('[toolbar] onClick');\n const change = value.change();\n const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);\n\n if (currentRespAreaList.size >= opts.maxResponseAreas) {\n return;\n }\n\n const type = opts.type.replace(/-/g, '_');\n const prevIndex = lastIndexMap[type];\n const newIndex = prevIndex === 0 ? prevIndex : prevIndex + 1;\n const newInline = getDefaultElement(opts, newIndex);\n\n lastIndexMap[type] += 1;\n\n if (newInline) {\n if (change.value.selection.startKey || change.value.selection.endKey) {\n change.insertInline(newInline);\n } else {\n // If the markup is empty and there's no focus\n const lastText = value.document.getLastText();\n\n if (!lastText) {\n return;\n }\n const parentNode = value.document.getParent(lastText.key);\n\n if (parentNode) {\n const index = parentNode.nodes.indexOf(lastText.key);\n\n if (parentNode.isVoid) return;\n\n change.insertNodeByKey(parentNode.key, index + 1, newInline);\n }\n }\n\n if (newInline.type === 'drag_in_the_blank') {\n const nextText = change.value.document.getNextText(newInline.key);\n\n if (nextText) {\n change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);\n }\n }\n\n onChange(change);\n }\n },\n customToolbar: opts.respAreaToolbar,\n supports: (node) => node.object === 'inline' && elTypesArray.indexOf(node.type) >= 0,\n showDone: false,\n };\n\n return {\n name: 'response_area',\n toolbar,\n filterPlugins: (node, plugins) => {\n if (node.type === 'explicit_constructed_response' || node.type === 'drag_in_the_blank') {\n return [];\n }\n\n return plugins.filter((p) => p.name !== 'response_area');\n },\n deleteNode: (e, node, value, onChange) => {\n e.preventDefault();\n\n const change = value.change().removeNodeByKey(node.key);\n\n onChange(change);\n },\n renderNode(props) {\n const { attributes, node: n } = props;\n\n if (n.type === 'explicit_constructed_response') {\n const data = n.data.toJSON();\n let error;\n\n if (opts.error) {\n error = opts.error();\n }\n\n return (\n <ExplicitConstructedResponse\n attributes={attributes}\n value={data.value}\n error={error && error[data.index] && error[data.index][0]}\n />\n );\n }\n\n if (n.type === 'drag_in_the_blank') {\n const data = n.data.toJSON();\n\n return <DragInTheBlank attributes={attributes} data={data} n={n} nodeProps={props} opts={opts} />;\n }\n\n if (n.type === 'inline_dropdown') {\n const data = n.data.toJSON();\n\n return <InlineDropdown attributes={attributes} selectedItem={data.value} />;\n }\n },\n onChange(change, editor) {\n const type = opts.type.replace(/-/g, '_');\n\n if (isUndefined(lastIndexMap[type])) {\n lastIndexMap[type] = 0;\n\n change.value.document.forEachDescendant((d) => {\n if (d.type === type) {\n const newIndex = parseInt(d.data.get('index'), 10);\n\n if (newIndex > lastIndexMap[type]) {\n lastIndexMap[type] = newIndex;\n }\n }\n });\n }\n\n if (!editor.value) {\n return;\n }\n\n const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);\n const oldRespAreaList = editor.value.document.filterDescendants(isOfCurrentType);\n\n if (currentRespAreaList.size >= opts.maxResponseAreas) {\n toolbar.disabled = true;\n } else {\n toolbar.disabled = false;\n }\n\n const arrayToFilter = oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;\n const arrayToUseForFilter = arrayToFilter === oldRespAreaList ? currentRespAreaList : oldRespAreaList;\n\n const elementsWithChangedStatus = arrayToFilter.filter(\n (d) => !arrayToUseForFilter.find((e) => e.data.get('index') === d.data.get('index')),\n );\n\n if (elementsWithChangedStatus.size && oldRespAreaList.size > currentRespAreaList.size) {\n opts.onHandleAreaChange(elementsWithChangedStatus);\n }\n },\n onDrop(event, change, editor) {\n const closestEl = event.target.closest('[data-key]');\n const inline = editor.value.document.findDescendant((d) => d.key === closestEl.dataset.key);\n\n if (inline.type === 'drag_in_the_blank') {\n return false;\n }\n },\n };\n}\n\nexport const serialization = {\n deserialize(el) {\n const type = el.dataset && el.dataset.type;\n\n switch (type) {\n case 'inline_dropdown':\n return {\n object: 'inline',\n type: 'inline_dropdown',\n isVoid: true,\n data: {\n index: el.dataset.index,\n value: el.dataset.value,\n },\n };\n case 'explicit_constructed_response':\n return {\n object: 'inline',\n type: 'explicit_constructed_response',\n isVoid: true,\n data: {\n index: el.dataset.index,\n value: el.dataset.value,\n },\n };\n case 'drag_in_the_blank':\n return {\n object: 'inline',\n type: 'drag_in_the_blank',\n isVoid: true,\n data: {\n index: el.dataset.index,\n id: el.dataset.id,\n value: el.dataset.value,\n inTable: el.dataset.inTable,\n },\n };\n }\n },\n serialize(object) {\n if (object.object !== 'inline') {\n return;\n }\n\n switch (object.type) {\n case 'inline_dropdown': {\n const data = object.data.toJSON();\n\n return <span data-type=\"inline_dropdown\" data-index={data.index} data-value={data.value} />;\n }\n case 'explicit_constructed_response': {\n const data = object.data.toJSON();\n\n return <span data-type=\"explicit_constructed_response\" data-index={data.index} data-value={data.value} />;\n }\n case 'drag_in_the_blank': {\n const data = object.data.toJSON();\n\n return (\n <span\n data-type=\"drag_in_the_blank\"\n data-index={data.index}\n data-id={data.id}\n data-value={data.value}\n data-in-table={data.inTable}\n />\n );\n }\n }\n },\n};\n"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/respArea/index.jsx"],"names":["log","lastIndexMap","elTypesMap","elTypesArray","Object","values","ResponseAreaPlugin","opts","isOfCurrentType","d","type","toolbar","icon","buttonStyles","margin","onClick","value","onChange","change","currentRespAreaList","document","filterDescendants","size","maxResponseAreas","replace","prevIndex","newIndex","newInline","selection","startKey","endKey","insertInline","lastText","getLastText","parentNode","getParent","key","index","nodes","indexOf","isVoid","insertNodeByKey","nextText","getNextText","moveFocusTo","moveAnchorTo","customToolbar","respAreaToolbar","supports","node","object","showDone","name","filterPlugins","plugins","filter","p","deleteNode","e","preventDefault","removeNodeByKey","renderNode","props","attributes","n","isFocused","data","toJSON","error","keyToDisplay","parseInt","editor","forEachDescendant","get","oldRespAreaList","disabled","arrayToFilter","arrayToUseForFilter","elementsWithChangedStatus","find","onHandleAreaChange","onDrop","event","closestEl","target","closest","inline","findDescendant","dataset","serialization","deserialize","el","id","inTable","serialize"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,GAAG,GAAG,uBAAM,yCAAN,CAAZ;AAEA,IAAMC,YAAY,GAAG,EAArB;AACA,IAAMC,UAAU,GAAG;AACjB,qBAAmB,iBADF;AAEjB,m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AP,CAAYC,MAAZ,EAAb;;AAEA,8BAAO;AAAM,yBAAU,gBAAhB;AAAiC,0BAAYD,MAAI,CAAC7B,KAAlD;AAAyD,0BAAY6B,MAAI,CAAClD;AAA1E,YAAP;AACD;;AACD,WAAK,mBAAL;AAA0B;AACxB,cAAMkD,MAAI,GAAGhB,MAAM,CAACgB,IAAP,CAAYC,MAAZ,EAAb;;AAEA,8BACE;AACE,yBAAU,mBADZ;AAEE,0BAAYD,MAAI,CAAC7B,KAFnB;AAGE,uBAAS6B,MAAI,CAAC0B,EAHhB;AAIE,0BAAY1B,MAAI,CAAClD,KAJnB;AAKE,6BAAekD,MAAI,CAAC2B;AALtB,YADF;AASD;AA5BH;AA8BD;AApF0B,CAAtB","sourcesContent":["import React from 'react';\nimport debug from 'debug';\nimport isUndefined from 'lodash/isUndefined';\n\nimport InlineDropdown from './inline-dropdown';\nimport DragInTheBlank from './drag-in-the-blank';\nimport ExplicitConstructedResponse from './explicit-constructed-response';\nimport MathTemplated from './math-templated';\nimport { getDefaultElement } from './utils';\nimport { ToolbarIcon } from './icons';\n\nconst log = debug('@pie-lib:editable-html:plugins:respArea');\n\nconst lastIndexMap = {};\nconst elTypesMap = {\n 'inline-dropdown': 'inline_dropdown',\n 'explicit-constructed-response': 'explicit_constructed_response',\n 'math-templated': 'math_templated',\n 'drag-in-the-blank': 'drag_in_the_blank',\n};\nconst elTypesArray = Object.values(elTypesMap);\n\nexport default function ResponseAreaPlugin(opts) {\n const isOfCurrentType = (d) => d.type === opts.type || d.type === elTypesMap[opts.type];\n\n const toolbar = {\n icon: <ToolbarIcon />,\n buttonStyles: {\n margin: '0 20px 0 auto',\n },\n onClick: (value, onChange) => {\n log('[toolbar] onClick');\n const change = value.change();\n const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);\n\n if (currentRespAreaList.size >= opts.maxResponseAreas) {\n return;\n }\n\n const type = opts.type.replace(/-/g, '_');\n const prevIndex = lastIndexMap[type];\n const newIndex = prevIndex === 0 ? prevIndex : prevIndex + 1;\n const newInline = getDefaultElement(opts, newIndex);\n\n lastIndexMap[type] += 1;\n\n if (newInline) {\n if (change.value.selection.startKey || change.value.selection.endKey) {\n change.insertInline(newInline);\n } else {\n // If the markup is empty and there's no focus\n const lastText = value.document.getLastText();\n\n if (!lastText) {\n return;\n }\n const parentNode = value.document.getParent(lastText.key);\n\n if (parentNode) {\n const index = parentNode.nodes.indexOf(lastText.key);\n\n if (parentNode.isVoid) return;\n\n change.insertNodeByKey(parentNode.key, index + 1, newInline);\n }\n }\n\n if (newInline.type === 'drag_in_the_blank') {\n const nextText = change.value.document.getNextText(newInline.key);\n\n if (nextText) {\n change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);\n }\n }\n if (newInline.type === 'math_templated') {\n const nextText = change.value.document.getNextText(newInline.key);\n\n if (nextText) {\n change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);\n }\n }\n\n onChange(change);\n }\n },\n customToolbar: opts.respAreaToolbar,\n supports: (node) => node.object === 'inline' && elTypesArray.indexOf(node.type) >= 0,\n showDone: false,\n };\n\n return {\n name: 'response_area',\n toolbar,\n filterPlugins: (node, plugins) => {\n if (\n node.type === 'explicit_constructed_response' ||\n node.type === 'math_templated' ||\n node.type === 'drag_in_the_blank'\n ) {\n return [];\n }\n\n return plugins.filter((p) => p.name !== 'response_area');\n },\n deleteNode: (e, node, value, onChange) => {\n e.preventDefault();\n\n const change = value.change().removeNodeByKey(node.key);\n\n onChange(change);\n },\n renderNode(props) {\n const { attributes, node: n, isFocused } = props;\n\n if (n.type === 'explicit_constructed_response') {\n const data = n.data.toJSON();\n let error;\n\n if (opts.error) {\n error = opts.error();\n }\n\n return (\n <ExplicitConstructedResponse\n attributes={attributes}\n isFocused={isFocused}\n value={data.value}\n error={error && error[data.index] && error[data.index][0]}\n />\n );\n }\n\n if (n.type === 'math_templated') {\n const data = n.data.toJSON();\n let error;\n\n if (opts.error) {\n error = opts.error();\n }\n\n // add 1 to index to display R 1 instead of R 0\n const keyToDisplay = `R ${parseInt(data.index) + 1}`;\n\n return (\n <MathTemplated\n attributes={attributes}\n keyToDisplay={keyToDisplay}\n value={data.value || ''}\n error={error && error[data.index] && error[data.index][0]}\n />\n );\n }\n\n if (n.type === 'drag_in_the_blank') {\n const data = n.data.toJSON();\n\n return <DragInTheBlank attributes={attributes} data={data} n={n} nodeProps={props} opts={opts} />;\n }\n\n if (n.type === 'inline_dropdown') {\n const data = n.data.toJSON();\n\n return <InlineDropdown attributes={attributes} selectedItem={data.value} />;\n }\n },\n onChange(change, editor) {\n const type = opts.type.replace(/-/g, '_');\n\n if (isUndefined(lastIndexMap[type])) {\n lastIndexMap[type] = 0;\n\n change.value.document.forEachDescendant((d) => {\n if (d.type === type) {\n const newIndex = parseInt(d.data.get('index'), 10);\n\n if (newIndex > lastIndexMap[type]) {\n lastIndexMap[type] = newIndex;\n }\n }\n });\n }\n\n if (!editor.value) {\n return;\n }\n\n const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);\n const oldRespAreaList = editor.value.document.filterDescendants(isOfCurrentType);\n\n toolbar.disabled = currentRespAreaList.size >= opts.maxResponseAreas;\n\n const arrayToFilter = oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;\n const arrayToUseForFilter = arrayToFilter === oldRespAreaList ? currentRespAreaList : oldRespAreaList;\n\n const elementsWithChangedStatus = arrayToFilter.filter(\n (d) => !arrayToUseForFilter.find((e) => e.data.get('index') === d.data.get('index')),\n );\n\n if (elementsWithChangedStatus.size && oldRespAreaList.size > currentRespAreaList.size) {\n opts.onHandleAreaChange(elementsWithChangedStatus);\n }\n },\n onDrop(event, change, editor) {\n const closestEl = event.target.closest('[data-key]');\n const inline = editor.value.document.findDescendant((d) => d.key === closestEl.dataset.key);\n\n if (inline.type === 'drag_in_the_blank') {\n return false;\n }\n },\n };\n}\n\nexport const serialization = {\n deserialize(el) {\n const type = el.dataset && el.dataset.type;\n\n switch (type) {\n case 'inline_dropdown':\n return {\n object: 'inline',\n type: 'inline_dropdown',\n isVoid: true,\n data: {\n index: el.dataset.index,\n value: el.dataset.value,\n },\n };\n case 'explicit_constructed_response':\n return {\n object: 'inline',\n type: 'explicit_constructed_response',\n isVoid: true,\n data: {\n index: el.dataset.index,\n value: el.dataset.value,\n },\n };\n case 'math_templated':\n return {\n object: 'inline',\n type: 'math_templated',\n isVoid: true,\n data: {\n index: el.dataset.index,\n value: el.dataset.value,\n },\n };\n case 'drag_in_the_blank':\n return {\n object: 'inline',\n type: 'drag_in_the_blank',\n isVoid: true,\n data: {\n index: el.dataset.index,\n id: el.dataset.id,\n value: el.dataset.value,\n inTable: el.dataset.inTable,\n },\n };\n }\n },\n serialize(object) {\n if (object.object !== 'inline') {\n return;\n }\n\n switch (object.type) {\n case 'inline_dropdown': {\n const data = object.data.toJSON();\n\n return <span data-type=\"inline_dropdown\" data-index={data.index} data-value={data.value} />;\n }\n case 'explicit_constructed_response': {\n const data = object.data.toJSON();\n\n return <span data-type=\"explicit_constructed_response\" data-index={data.index} data-value={data.value} />;\n }\n case 'math_templated': {\n const data = object.data.toJSON();\n\n return <span data-type=\"math_templated\" data-index={data.index} data-value={data.value} />;\n }\n case 'drag_in_the_blank': {\n const data = object.data.toJSON();\n\n return (\n <span\n data-type=\"drag_in_the_blank\"\n data-index={data.index}\n data-id={data.id}\n data-value={data.value}\n data-in-table={data.inTable}\n />\n );\n }\n }\n },\n};\n"],"file":"index.js"}
|
|
@@ -13,7 +13,7 @@ var _react = _interopRequireDefault(require("react"));
|
|
|
13
13
|
|
|
14
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
15
|
|
|
16
|
-
var _icons = require("
|
|
16
|
+
var _icons = require("@pie-lib/icons");
|
|
17
17
|
|
|
18
18
|
var InlineDropdown = function InlineDropdown(_ref) {
|
|
19
19
|
var attributes = _ref.attributes,
|
|
@@ -37,7 +37,8 @@ var InlineDropdown = function InlineDropdown(_ref) {
|
|
|
37
37
|
border: '1px solid #C0C3CF',
|
|
38
38
|
boxSizing: 'border-box',
|
|
39
39
|
borderRadius: '3px',
|
|
40
|
-
position: 'relative'
|
|
40
|
+
position: 'relative',
|
|
41
|
+
alignItems: 'center'
|
|
41
42
|
}
|
|
42
43
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
43
44
|
style: {
|
|
@@ -45,13 +46,17 @@ var InlineDropdown = function InlineDropdown(_ref) {
|
|
|
45
46
|
overflow: 'hidden',
|
|
46
47
|
padding: '0 25px 0 8px',
|
|
47
48
|
whiteSpace: 'nowrap',
|
|
48
|
-
textOverflow: 'ellipsis'
|
|
49
|
-
|
|
49
|
+
textOverflow: 'ellipsis'
|
|
50
|
+
}
|
|
51
|
+
}, /*#__PURE__*/_react["default"].createElement("span", {
|
|
52
|
+
style: {
|
|
53
|
+
display: 'inline-block',
|
|
54
|
+
verticalAlign: 'middle'
|
|
50
55
|
},
|
|
51
56
|
dangerouslySetInnerHTML: {
|
|
52
57
|
__html: html
|
|
53
58
|
}
|
|
54
|
-
}), /*#__PURE__*/_react["default"].createElement(_icons.Chevron, {
|
|
59
|
+
})), /*#__PURE__*/_react["default"].createElement(_icons.Chevron, {
|
|
55
60
|
direction: "down",
|
|
56
61
|
style: {
|
|
57
62
|
position: 'absolute',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/respArea/inline-dropdown/index.jsx"],"names":["InlineDropdown","attributes","selectedItem","html","display","height","margin","cursor","minWidth","background","border","boxSizing","borderRadius","position","flex","overflow","padding","whiteSpace","textOverflow","
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/respArea/inline-dropdown/index.jsx"],"names":["InlineDropdown","attributes","selectedItem","html","display","height","margin","cursor","minWidth","background","border","boxSizing","borderRadius","position","alignItems","flex","overflow","padding","whiteSpace","textOverflow","verticalAlign","__html","top","right","propTypes","PropTypes","object","oneOfType","string"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA,IAAMA,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,CA1DD;;AA4DAvB,cAAc,CAACwB,SAAf,GAA2B;AACzBvB,EAAAA,UAAU,EAAEwB,sBAAUC,MADG;AAEzBxB,EAAAA,YAAY,EAAEuB,sBAAUE,SAAV,CAAoB,CAACF,sBAAUG,MAAX,EAAmBH,sBAAUC,MAA7B,CAApB;AAFW,CAA3B;eAKe1B,c","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Chevron } from '@pie-lib/icons';\n\nconst InlineDropdown = ({ attributes, selectedItem }) => {\n // TODO: Investigate\n // Needed because items with values inside have different positioning for some reason\n const html = selectedItem || '<div> </div>';\n\n return (\n <span\n {...attributes}\n style={{\n display: 'inline-flex',\n height: '50px',\n margin: '0 5px',\n cursor: 'pointer',\n }}\n >\n <div\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n height: '36px',\n background: '#FFF',\n border: '1px solid #C0C3CF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n position: 'relative',\n alignItems: 'center',\n }}\n >\n <div\n style={{\n flex: 1,\n overflow: 'hidden',\n padding: '0 25px 0 8px',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n }}\n >\n <span\n style={{\n display: 'inline-block',\n verticalAlign: 'middle',\n }}\n dangerouslySetInnerHTML={{\n __html: html,\n }}\n />\n </div>\n <Chevron\n direction=\"down\"\n style={{\n position: 'absolute',\n top: '5px',\n right: '5px',\n }}\n />\n </div>\n </span>\n );\n};\n\nInlineDropdown.propTypes = {\n attributes: PropTypes.object,\n selectedItem: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),\n};\n\nexport default InlineDropdown;\n"],"file":"index.js"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _react = _interopRequireDefault(require("react"));
|
|
13
|
+
|
|
14
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
+
|
|
16
|
+
var _styles = require("@material-ui/core/styles");
|
|
17
|
+
|
|
18
|
+
var _mathInput = require("@pie-lib/math-input");
|
|
19
|
+
|
|
20
|
+
var MathTemplated = function MathTemplated(_ref) {
|
|
21
|
+
var attributes = _ref.attributes,
|
|
22
|
+
value = _ref.value,
|
|
23
|
+
classes = _ref.classes,
|
|
24
|
+
keyToDisplay = _ref.keyToDisplay;
|
|
25
|
+
return /*#__PURE__*/_react["default"].createElement("span", (0, _extends2["default"])({}, attributes, {
|
|
26
|
+
className: classes.spanContainer
|
|
27
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
28
|
+
className: classes.responseBox
|
|
29
|
+
}, keyToDisplay), /*#__PURE__*/_react["default"].createElement("div", {
|
|
30
|
+
className: classes.mathBlock
|
|
31
|
+
}, /*#__PURE__*/_react["default"].createElement(_mathInput.mq.Static, {
|
|
32
|
+
latex: value
|
|
33
|
+
})));
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
MathTemplated.propTypes = {
|
|
37
|
+
attributes: _propTypes["default"].object,
|
|
38
|
+
classes: _propTypes["default"].object.isRequired,
|
|
39
|
+
value: _propTypes["default"].string,
|
|
40
|
+
keyToDisplay: _propTypes["default"].string
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
var styles = function styles(theme) {
|
|
44
|
+
return {
|
|
45
|
+
responseBox: {
|
|
46
|
+
background: theme.palette.grey['A100'],
|
|
47
|
+
color: theme.palette.grey['A700'],
|
|
48
|
+
display: 'inline-flex',
|
|
49
|
+
borderRight: '2px solid #C0C3CF',
|
|
50
|
+
boxSizing: 'border-box',
|
|
51
|
+
overflow: 'hidden',
|
|
52
|
+
fontSize: '12px',
|
|
53
|
+
minHeight: '36px',
|
|
54
|
+
height: '100%',
|
|
55
|
+
alignItems: 'center',
|
|
56
|
+
fontFamily: 'Symbola, Times New Roman, serif',
|
|
57
|
+
padding: '0 2px'
|
|
58
|
+
},
|
|
59
|
+
spanContainer: {
|
|
60
|
+
display: 'inline-flex',
|
|
61
|
+
border: '1px solid #C0C3CF',
|
|
62
|
+
margin: '1px 5px',
|
|
63
|
+
cursor: 'pointer',
|
|
64
|
+
alignItems: 'center',
|
|
65
|
+
justifyContent: 'center',
|
|
66
|
+
minWidth: '50px',
|
|
67
|
+
minHeight: '36px',
|
|
68
|
+
height: 'fit-content'
|
|
69
|
+
},
|
|
70
|
+
mathBlock: {
|
|
71
|
+
flex: 8,
|
|
72
|
+
color: 'var(--pie-text, black)',
|
|
73
|
+
padding: '4px !important',
|
|
74
|
+
display: 'flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
backgroundColor: 'var(--pie-background, rgba(255, 255, 255, 0))',
|
|
78
|
+
'& > .mq-math-mode sup.mq-nthroot': {
|
|
79
|
+
fontSize: '70% !important',
|
|
80
|
+
verticalAlign: '1em !important'
|
|
81
|
+
},
|
|
82
|
+
'& > .mq-math-mode .mq-sqrt-stem': {
|
|
83
|
+
borderTop: '0.07em solid',
|
|
84
|
+
marginLeft: '-1.5px',
|
|
85
|
+
marginTop: '-2px !important',
|
|
86
|
+
paddingTop: '5px !important'
|
|
87
|
+
},
|
|
88
|
+
'& .mq-overarrow-inner': {
|
|
89
|
+
paddingTop: '0 !important',
|
|
90
|
+
border: 'none !important'
|
|
91
|
+
},
|
|
92
|
+
'& .mq-overarrow.mq-arrow-both': {
|
|
93
|
+
marginTop: '0px',
|
|
94
|
+
minWidth: '1.23em',
|
|
95
|
+
'& *': {
|
|
96
|
+
lineHeight: '1 !important'
|
|
97
|
+
},
|
|
98
|
+
'&:before': {
|
|
99
|
+
top: '-0.4em',
|
|
100
|
+
left: '-1px'
|
|
101
|
+
},
|
|
102
|
+
'&:after': {
|
|
103
|
+
top: '0px !important',
|
|
104
|
+
position: 'absolute !important',
|
|
105
|
+
right: '-2px'
|
|
106
|
+
},
|
|
107
|
+
'&.mq-empty:after': {
|
|
108
|
+
top: '-0.45em'
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
'& .mq-overarrow.mq-arrow-right': {
|
|
112
|
+
'&:before': {
|
|
113
|
+
top: '-0.4em',
|
|
114
|
+
right: '-1px'
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
'& .mq-overarrow-inner-right': {
|
|
118
|
+
display: 'none !important'
|
|
119
|
+
},
|
|
120
|
+
'& .mq-overarrow-inner-left': {
|
|
121
|
+
display: 'none !important'
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
var _default = (0, _styles.withStyles)(styles)(MathTemplated);
|
|
128
|
+
|
|
129
|
+
exports["default"] = _default;
|
|
130
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/respArea/math-templated/index.jsx"],"names":["MathTemplated","attributes","value","classes","keyToDisplay","spanContainer","responseBox","mathBlock","propTypes","PropTypes","object","isRequired","string","styles","theme","background","palette","grey","color","display","borderRight","boxSizing","overflow","fontSize","minHeight","height","alignItems","fontFamily","padding","border","margin","cursor","justifyContent","minWidth","flex","backgroundColor","verticalAlign","borderTop","marginLeft","marginTop","paddingTop","lineHeight","top","left","position","right"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA,IAAMA,aAAa,GAAG,SAAhBA,aAAgB;AAAA,MAAGC,UAAH,QAAGA,UAAH;AAAA,MAAeC,KAAf,QAAeA,KAAf;AAAA,MAAsBC,OAAtB,QAAsBA,OAAtB;AAAA,MAA+BC,YAA/B,QAA+BA,YAA/B;AAAA,sBACpB,sEAAUH,UAAV;AAAsB,IAAA,SAAS,EAAE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CT,qCAA+B;AAC7B1B,QAAAA,OAAO,EAAE;AADoB,OA/CtB;AAkDT,oCAA8B;AAC5BA,QAAAA,OAAO,EAAE;AADmB;AAlDrB;AA1Bc,GAAZ;AAAA,CAAf;;eAkFe,wBAAWN,MAAX,EAAmBb,aAAnB,C","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport { mq } from '@pie-lib/math-input';\n\nconst MathTemplated = ({ attributes, value, classes, keyToDisplay }) => (\n <span {...attributes} className={classes.spanContainer}>\n <div className={classes.responseBox}>{keyToDisplay}</div>\n <div className={classes.mathBlock}>\n <mq.Static latex={value} />\n </div>\n </span>\n);\n\nMathTemplated.propTypes = {\n attributes: PropTypes.object,\n classes: PropTypes.object.isRequired,\n value: PropTypes.string,\n keyToDisplay: PropTypes.string,\n};\n\nconst styles = (theme) => ({\n responseBox: {\n background: theme.palette.grey['A100'],\n color: theme.palette.grey['A700'],\n display: 'inline-flex',\n borderRight: '2px solid #C0C3CF',\n boxSizing: 'border-box',\n overflow: 'hidden',\n fontSize: '12px',\n minHeight: '36px',\n height: '100%',\n alignItems: 'center',\n fontFamily: 'Symbola, Times New Roman, serif',\n padding: '0 2px',\n },\n spanContainer: {\n display: 'inline-flex',\n border: '1px solid #C0C3CF',\n margin: '1px 5px',\n cursor: 'pointer',\n alignItems: 'center',\n justifyContent: 'center',\n minWidth: '50px',\n minHeight: '36px',\n height: 'fit-content',\n },\n mathBlock: {\n flex: 8,\n color: 'var(--pie-text, black)',\n padding: '4px !important',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'var(--pie-background, rgba(255, 255, 255, 0))',\n '& > .mq-math-mode sup.mq-nthroot': {\n fontSize: '70% !important',\n verticalAlign: '1em !important',\n },\n '& > .mq-math-mode .mq-sqrt-stem': {\n borderTop: '0.07em solid',\n marginLeft: '-1.5px',\n marginTop: '-2px !important',\n paddingTop: '5px !important',\n },\n '& .mq-overarrow-inner': {\n paddingTop: '0 !important',\n border: 'none !important',\n },\n '& .mq-overarrow.mq-arrow-both': {\n marginTop: '0px',\n minWidth: '1.23em',\n '& *': {\n lineHeight: '1 !important',\n },\n '&:before': {\n top: '-0.4em',\n left: '-1px',\n },\n '&:after': {\n top: '0px !important',\n position: 'absolute !important',\n right: '-2px',\n },\n '&.mq-empty:after': {\n top: '-0.45em',\n },\n },\n '& .mq-overarrow.mq-arrow-right': {\n '&:before': {\n top: '-0.4em',\n right: '-1px',\n },\n },\n '& .mq-overarrow-inner-right': {\n display: 'none !important',\n },\n '& .mq-overarrow-inner-left': {\n display: 'none !important',\n },\n },\n});\n\nexport default withStyles(styles)(MathTemplated);\n"],"file":"index.js"}
|
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.isNumber = exports.insertSnackBar = exports.getDefaultElement = exports.defaultIDD = exports.defaultECR = exports.defaultDIB = void 0;
|
|
8
|
+
exports.isNumber = exports.insertSnackBar = exports.getDefaultElement = exports.defaultMT = exports.defaultIDD = exports.defaultECR = exports.defaultDIB = void 0;
|
|
9
9
|
|
|
10
10
|
var _react = _interopRequireDefault(require("react"));
|
|
11
11
|
|
|
@@ -65,6 +65,18 @@ var defaultECR = function defaultECR(index) {
|
|
|
65
65
|
|
|
66
66
|
exports.defaultECR = defaultECR;
|
|
67
67
|
|
|
68
|
+
var defaultMT = function defaultMT(index) {
|
|
69
|
+
return _slate.Inline.create({
|
|
70
|
+
type: 'math_templated',
|
|
71
|
+
isVoid: true,
|
|
72
|
+
data: {
|
|
73
|
+
index: index
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
exports.defaultMT = defaultMT;
|
|
79
|
+
|
|
68
80
|
var defaultDIB = function defaultDIB(opts, index) {
|
|
69
81
|
return _slate.Inline.create({
|
|
70
82
|
type: 'drag_in_the_blank',
|
|
@@ -97,6 +109,9 @@ var getDefaultElement = function getDefaultElement(opts, index) {
|
|
|
97
109
|
case 'explicit-constructed-response':
|
|
98
110
|
return defaultECR(index);
|
|
99
111
|
|
|
112
|
+
case 'math-templated':
|
|
113
|
+
return defaultMT(index);
|
|
114
|
+
|
|
100
115
|
case 'drag-in-the-blank':
|
|
101
116
|
return defaultDIB(opts, index);
|
|
102
117
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/respArea/utils.jsx"],"names":["isNumber","val","isNaN","parseFloat","isFinite","insertSnackBar","message","prevSnacks","document","querySelectorAll","forEach","s","remove","newEl","createElement","className","el","vertical","horizontal","ReactDOM","render","body","appendChild","setTimeout","defaultECR","index","Inline","create","type","isVoid","data","defaultDIB","opts","duplicates","options","value","defaultIDD","object","getDefaultElement"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,GAAD;AAAA,SAAS,CAACC,KAAK,CAACC,UAAU,CAACF,GAAD,CAAX,CAAN,IAA2BG,QAAQ,CAACH,GAAD,CAA5C;AAAA,CAAjB;;;;AAEA,IAAMI,cAAc,GAAG,SAAjBA,cAAiB,CAACC,OAAD,EAAa;AACzC,MAAMC,UAAU,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,sBAA1B,CAAnB;AAEAF,EAAAA,UAAU,CAACG,OAAX,CAAmB,UAACC,CAAD;AAAA,WAAOA,CAAC,CAACC,MAAF,EAAP;AAAA,GAAnB;AAEA,MAAMC,KAAK,GAAGL,QAAQ,CAACM,aAAT,CAAuB,KAAvB,CAAd;AAEAD,EAAAA,KAAK,CAACE,SAAN,GAAkB,qBAAlB;;AAEA,MAAMC,EAAE,gBACN,gCAAC,oBAAD;AACE,IAAA,YAAY,EAAE;AAAEC,MAAAA,QAAQ,EAAE,KAAZ;AAAmBC,MAAAA,UAAU,EAAE;AAA/B,KADhB;AAEE,IAAA,IAAI,EAAE,IAFR;AAGE,IAAA,YAAY,EAAE;AACZ,0BAAoB;AADR,KAHhB;AAME,IAAA,OAAO,eAAE;AAAM,MAAA,EAAE,EAAC;AAAT,OAAuBZ,OAAvB;AANX,IADF;;AAWAa,uBAASC,MAAT,CAAgBJ,EAAhB,EAAoBH,KAApB;;AAEAL,EAAAA,QAAQ,CAACa,IAAT,CAAcC,WAAd,CAA0BT,KAA1B;AAEAU,EAAAA,UAAU,CAAC,YAAM;AACfV,IAAAA,KAAK,CAACD,MAAN;AACD,GAFS,EAEP,IAFO,CAAV;AAGD,CA3BM;;;;AA6BA,IAAMY,UAAU,GAAG,SAAbA,UAAa,CAACC,KAAD;AAAA,SACxBC,cAAOC,MAAP,CAAc;AACZC,IAAAA,IAAI,EAAE,+BADM;AAEZC,IAAAA,MAAM,EAAE,IAFI;AAGZC,IAAAA,IAAI,EAAE;AACJL,MAAAA,KAAK,EAALA;AADI;AAHM,GAAd,CADwB;AAAA,CAAnB;;;;
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/respArea/utils.jsx"],"names":["isNumber","val","isNaN","parseFloat","isFinite","insertSnackBar","message","prevSnacks","document","querySelectorAll","forEach","s","remove","newEl","createElement","className","el","vertical","horizontal","ReactDOM","render","body","appendChild","setTimeout","defaultECR","index","Inline","create","type","isVoid","data","defaultMT","defaultDIB","opts","duplicates","options","value","defaultIDD","object","getDefaultElement"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAACC,GAAD;AAAA,SAAS,CAACC,KAAK,CAACC,UAAU,CAACF,GAAD,CAAX,CAAN,IAA2BG,QAAQ,CAACH,GAAD,CAA5C;AAAA,CAAjB;;;;AAEA,IAAMI,cAAc,GAAG,SAAjBA,cAAiB,CAACC,OAAD,EAAa;AACzC,MAAMC,UAAU,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,sBAA1B,CAAnB;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UAAU,GAAG,SAAbA,UAAa,CAACC,IAAD,EAAOR,KAAP;AAAA,SACxBC,cAAOC,MAAP,CAAc;AACZC,IAAAA,IAAI,EAAE,mBADM;AAEZC,IAAAA,MAAM,EAAE,IAFI;AAGZC,IAAAA,IAAI,EAAE;AACJL,MAAAA,KAAK,EAALA,KADI;AAEJS,MAAAA,UAAU,EAAED,IAAI,CAACE,OAAL,CAAaD,UAFrB;AAGJE,MAAAA,KAAK,EAAE;AAHH;AAHM,GAAd,CADwB;AAAA,CAAnB;;;;AAWA,IAAMC,UAAU,GAAG,SAAbA,UAAa,CAACZ,KAAD;AAAA,SACxBC,cAAOC,MAAP,CAAc;AACZW,IAAAA,MAAM,EAAE,QADI;AAEZV,IAAAA,IAAI,EAAE,iBAFM;AAGZC,IAAAA,MAAM,EAAE,IAHI;AAIZC,IAAAA,IAAI,EAAE;AACJL,MAAAA,KAAK,EAALA;AADI;AAJM,GAAd,CADwB;AAAA,CAAnB;;;;AAUA,IAAMc,iBAAiB,GAAG,SAApBA,iBAAoB,CAACN,IAAD,EAAOR,KAAP,EAAiB;AAChD,UAAQQ,IAAI,CAACL,IAAb;AACE,SAAK,+BAAL;AACE,aAAOJ,UAAU,CAACC,KAAD,CAAjB;;AAEF,SAAK,gBAAL;AACE,aAAOM,SAAS,CAACN,KAAD,CAAhB;;AAEF,SAAK,mBAAL;AACE,aAAOO,UAAU,CAACC,IAAD,EAAOR,KAAP,CAAjB;;AAEF;AACE;AACA,aAAOY,UAAU,CAACZ,KAAD,CAAjB;AAZJ;AAcD,CAfM","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Inline } from 'slate';\nimport Snackbar from '@material-ui/core/Snackbar';\n\nexport const isNumber = (val) => !isNaN(parseFloat(val)) && isFinite(val);\n\nexport const insertSnackBar = (message) => {\n const prevSnacks = document.querySelectorAll('.response-area-alert');\n\n prevSnacks.forEach((s) => s.remove());\n\n const newEl = document.createElement('div');\n\n newEl.className = 'response-area-alert';\n\n const el = (\n <Snackbar\n anchorOrigin={{ vertical: 'top', horizontal: 'center' }}\n open={true}\n ContentProps={{\n 'aria-describedby': 'message-id',\n }}\n message={<span id=\"message-id\">{message}</span>}\n />\n );\n\n ReactDOM.render(el, newEl);\n\n document.body.appendChild(newEl);\n\n setTimeout(() => {\n newEl.remove();\n }, 2000);\n};\n\nexport const defaultECR = (index) =>\n Inline.create({\n type: 'explicit_constructed_response',\n isVoid: true,\n data: {\n index,\n },\n });\nexport const defaultMT = (index) =>\n Inline.create({\n type: 'math_templated',\n isVoid: true,\n data: {\n index,\n },\n });\n\nexport const defaultDIB = (opts, index) =>\n Inline.create({\n type: 'drag_in_the_blank',\n isVoid: true,\n data: {\n index,\n duplicates: opts.options.duplicates,\n value: null,\n },\n });\n\nexport const defaultIDD = (index) =>\n Inline.create({\n object: 'inline',\n type: 'inline_dropdown',\n isVoid: true,\n data: {\n index,\n },\n });\n\nexport const getDefaultElement = (opts, index) => {\n switch (opts.type) {\n case 'explicit-constructed-response':\n return defaultECR(index);\n\n case 'math-templated':\n return defaultMT(index);\n\n case 'drag-in-the-blank':\n return defaultDIB(opts, index);\n\n default:\n // inline-dropdown\n return defaultIDD(index);\n }\n};\n"],"file":"utils.js"}
|