@pie-lib/editable-html 11.7.0 → 11.9.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +6 -10
  2. package/lib/block-tags.js +25 -0
  3. package/lib/block-tags.js.map +1 -0
  4. package/lib/constants.js +16 -0
  5. package/lib/constants.js.map +1 -0
  6. package/lib/editor.js +1355 -0
  7. package/lib/editor.js.map +1 -0
  8. package/lib/index.js +269 -0
  9. package/lib/index.js.map +1 -0
  10. package/lib/parse-html.js +16 -0
  11. package/lib/parse-html.js.map +1 -0
  12. package/lib/plugins/characters/custom-popper.js +73 -0
  13. package/lib/plugins/characters/custom-popper.js.map +1 -0
  14. package/lib/plugins/characters/index.js +305 -0
  15. package/lib/plugins/characters/index.js.map +1 -0
  16. package/lib/plugins/characters/utils.js +381 -0
  17. package/lib/plugins/characters/utils.js.map +1 -0
  18. package/lib/plugins/css/icons/index.js +37 -0
  19. package/lib/plugins/css/icons/index.js.map +1 -0
  20. package/lib/plugins/css/index.js +397 -0
  21. package/lib/plugins/css/index.js.map +1 -0
  22. package/lib/plugins/customPlugin/index.js +114 -0
  23. package/lib/plugins/customPlugin/index.js.map +1 -0
  24. package/lib/plugins/html/icons/index.js +38 -0
  25. package/lib/plugins/html/icons/index.js.map +1 -0
  26. package/lib/plugins/html/index.js +80 -0
  27. package/lib/plugins/html/index.js.map +1 -0
  28. package/lib/plugins/image/alt-dialog.js +129 -0
  29. package/lib/plugins/image/alt-dialog.js.map +1 -0
  30. package/lib/plugins/image/component.js +419 -0
  31. package/lib/plugins/image/component.js.map +1 -0
  32. package/lib/plugins/image/image-toolbar.js +177 -0
  33. package/lib/plugins/image/image-toolbar.js.map +1 -0
  34. package/lib/plugins/image/index.js +263 -0
  35. package/lib/plugins/image/index.js.map +1 -0
  36. package/lib/plugins/image/insert-image-handler.js +161 -0
  37. package/lib/plugins/image/insert-image-handler.js.map +1 -0
  38. package/lib/plugins/index.js +402 -0
  39. package/lib/plugins/index.js.map +1 -0
  40. package/lib/plugins/list/index.js +334 -0
  41. package/lib/plugins/list/index.js.map +1 -0
  42. package/lib/plugins/math/index.js +454 -0
  43. package/lib/plugins/math/index.js.map +1 -0
  44. package/lib/plugins/media/index.js +387 -0
  45. package/lib/plugins/media/index.js.map +1 -0
  46. package/lib/plugins/media/media-dialog.js +709 -0
  47. package/lib/plugins/media/media-dialog.js.map +1 -0
  48. package/lib/plugins/media/media-toolbar.js +101 -0
  49. package/lib/plugins/media/media-toolbar.js.map +1 -0
  50. package/lib/plugins/media/media-wrapper.js +93 -0
  51. package/lib/plugins/media/media-wrapper.js.map +1 -0
  52. package/lib/plugins/rendering/index.js +46 -0
  53. package/lib/plugins/rendering/index.js.map +1 -0
  54. package/lib/plugins/respArea/drag-in-the-blank/choice.js +254 -0
  55. package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -0
  56. package/lib/plugins/respArea/drag-in-the-blank/index.js +97 -0
  57. package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -0
  58. package/lib/plugins/respArea/explicit-constructed-response/index.js +57 -0
  59. package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -0
  60. package/lib/plugins/respArea/icons/index.js +95 -0
  61. package/lib/plugins/respArea/icons/index.js.map +1 -0
  62. package/lib/plugins/respArea/index.js +341 -0
  63. package/lib/plugins/respArea/index.js.map +1 -0
  64. package/lib/plugins/respArea/inline-dropdown/index.js +75 -0
  65. package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -0
  66. package/lib/plugins/respArea/math-templated/index.js +130 -0
  67. package/lib/plugins/respArea/math-templated/index.js.map +1 -0
  68. package/lib/plugins/respArea/utils.js +125 -0
  69. package/lib/plugins/respArea/utils.js.map +1 -0
  70. package/lib/plugins/table/CustomTablePlugin.js +133 -0
  71. package/lib/plugins/table/CustomTablePlugin.js.map +1 -0
  72. package/lib/plugins/table/icons/index.js +69 -0
  73. package/lib/plugins/table/icons/index.js.map +1 -0
  74. package/lib/plugins/table/index.js +483 -0
  75. package/lib/plugins/table/index.js.map +1 -0
  76. package/lib/plugins/table/table-toolbar.js +187 -0
  77. package/lib/plugins/table/table-toolbar.js.map +1 -0
  78. package/lib/plugins/textAlign/icons/index.js +226 -0
  79. package/lib/plugins/textAlign/icons/index.js.map +1 -0
  80. package/lib/plugins/textAlign/index.js +34 -0
  81. package/lib/plugins/textAlign/index.js.map +1 -0
  82. package/lib/plugins/toolbar/default-toolbar.js +229 -0
  83. package/lib/plugins/toolbar/default-toolbar.js.map +1 -0
  84. package/lib/plugins/toolbar/done-button.js +53 -0
  85. package/lib/plugins/toolbar/done-button.js.map +1 -0
  86. package/lib/plugins/toolbar/editor-and-toolbar.js +286 -0
  87. package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -0
  88. package/lib/plugins/toolbar/index.js +34 -0
  89. package/lib/plugins/toolbar/index.js.map +1 -0
  90. package/lib/plugins/toolbar/toolbar-buttons.js +194 -0
  91. package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -0
  92. package/lib/plugins/toolbar/toolbar.js +376 -0
  93. package/lib/plugins/toolbar/toolbar.js.map +1 -0
  94. package/lib/plugins/utils.js +62 -0
  95. package/lib/plugins/utils.js.map +1 -0
  96. package/lib/serialization.js +677 -0
  97. package/lib/serialization.js.map +1 -0
  98. package/lib/shared/alert-dialog.js +75 -0
  99. package/lib/theme.js +9 -0
  100. package/lib/theme.js.map +1 -0
  101. package/package.json +8 -8
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.onValueChange = exports.onRemoveResponse = exports["default"] = void 0;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _react = _interopRequireDefault(require("react"));
15
+
16
+ var _propTypes = _interopRequireDefault(require("prop-types"));
17
+
18
+ var _choice = _interopRequireDefault(require("./choice"));
19
+
20
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
23
+
24
+ var onValueChange = function onValueChange(nodeProps, n, value) {
25
+ var val = nodeProps.editor.value;
26
+ var change = val.change();
27
+ change.setNodeByKey(n.key, {
28
+ data: _objectSpread(_objectSpread({}, value), {}, {
29
+ index: n.data.get('index')
30
+ })
31
+ });
32
+ nodeProps.editor.props.onChange(change, function () {
33
+ nodeProps.editor.props.onEditingDone();
34
+ });
35
+ };
36
+
37
+ exports.onValueChange = onValueChange;
38
+
39
+ var onRemoveResponse = function onRemoveResponse(nodeProps, value) {
40
+ var val = nodeProps.editor.value;
41
+ var change = val.change();
42
+ var dragInTheBlank = val.document.findDescendant(function (n) {
43
+ return n.data && n.data.get('index') === value.index;
44
+ });
45
+ change.setNodeByKey(dragInTheBlank.key, {
46
+ data: {
47
+ index: dragInTheBlank.data.get('index')
48
+ }
49
+ });
50
+ nodeProps.editor.props.onChange(change, function () {
51
+ nodeProps.editor.props.onEditingDone();
52
+ });
53
+ };
54
+
55
+ exports.onRemoveResponse = onRemoveResponse;
56
+
57
+ var DragDrop = function DragDrop(props) {
58
+ var attributes = props.attributes,
59
+ data = props.data,
60
+ n = props.n,
61
+ nodeProps = props.nodeProps,
62
+ opts = props.opts;
63
+ var inTable = data.inTable;
64
+ return /*#__PURE__*/_react["default"].createElement("span", (0, _extends2["default"])({}, attributes, {
65
+ style: {
66
+ display: 'inline-flex',
67
+ minHeight: '50px',
68
+ minWidth: '178px',
69
+ position: 'relative',
70
+ margin: inTable ? '10px' : '0 10px',
71
+ cursor: 'pointer'
72
+ }
73
+ }), /*#__PURE__*/_react["default"].createElement(_choice["default"], {
74
+ n: n,
75
+ dragKey: n.key,
76
+ targetId: "0",
77
+ value: data,
78
+ duplicates: opts.options.duplicates,
79
+ onChange: function onChange(value) {
80
+ return onValueChange(nodeProps, n, value);
81
+ },
82
+ removeResponse: function removeResponse(value) {
83
+ return onRemoveResponse(nodeProps, value);
84
+ }
85
+ }, nodeProps.children));
86
+ };
87
+
88
+ DragDrop.propTypes = {
89
+ attributes: _propTypes["default"].object,
90
+ data: _propTypes["default"].object,
91
+ n: _propTypes["default"].object,
92
+ nodeProps: _propTypes["default"].object,
93
+ opts: _propTypes["default"].object
94
+ };
95
+ var _default = DragDrop;
96
+ exports["default"] = _default;
97
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/plugins/respArea/drag-in-the-blank/index.jsx"],"names":["onValueChange","nodeProps","n","value","val","editor","change","setNodeByKey","key","data","index","get","props","onChange","onEditingDone","onRemoveResponse","dragInTheBlank","document","findDescendant","DragDrop","attributes","opts","inTable","display","minHeight","minWidth","position","margin","cursor","options","duplicates","children","propTypes","PropTypes","object"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,SAAD,EAAYC,CAAZ,EAAeC,KAAf,EAAyB;AACpD,MAAMC,GAAG,GAAGH,SAAS,CAACI,MAAV,CAAiBF,KAA7B;AACA,MAAMG,MAAM,GAAGF,GAAG,CAACE,MAAJ,EAAf;AAEAA,EA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sBAAUC,MAJF;AAKnBb,EAAAA,IAAI,EAAEY,sBAAUC;AALG,CAArB;eAQef,Q","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport DragDropTile from './choice';\n\nexport const onValueChange = (nodeProps, n, value) => {\n const val = nodeProps.editor.value;\n const change = val.change();\n\n change.setNodeByKey(n.key, {\n data: {\n ...value,\n index: n.data.get('index'),\n },\n });\n\n nodeProps.editor.props.onChange(change, () => {\n nodeProps.editor.props.onEditingDone();\n });\n};\n\nexport const onRemoveResponse = (nodeProps, value) => {\n const val = nodeProps.editor.value;\n const change = val.change();\n const dragInTheBlank = val.document.findDescendant((n) => n.data && n.data.get('index') === value.index);\n\n change.setNodeByKey(dragInTheBlank.key, {\n data: {\n index: dragInTheBlank.data.get('index'),\n },\n });\n\n nodeProps.editor.props.onChange(change, () => {\n nodeProps.editor.props.onEditingDone();\n });\n};\n\nconst DragDrop = (props) => {\n const { attributes, data, n, nodeProps, opts } = props;\n const { inTable } = data;\n\n return (\n <span\n {...attributes}\n style={{\n display: 'inline-flex',\n minHeight: '50px',\n minWidth: '178px',\n position: 'relative',\n margin: inTable ? '10px' : '0 10px',\n cursor: 'pointer',\n }}\n >\n <DragDropTile\n n={n}\n dragKey={n.key}\n targetId=\"0\"\n value={data}\n duplicates={opts.options.duplicates}\n onChange={(value) => onValueChange(nodeProps, n, value)}\n removeResponse={(value) => onRemoveResponse(nodeProps, value)}\n >\n {nodeProps.children}\n </DragDropTile>\n </span>\n );\n};\n\nDragDrop.propTypes = {\n attributes: PropTypes.object,\n data: PropTypes.object,\n n: PropTypes.object,\n nodeProps: PropTypes.object,\n opts: PropTypes.object,\n};\n\nexport default DragDrop;\n"],"file":"index.js"}
@@ -0,0 +1,57 @@
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 ExplicitConstructedResponse = function ExplicitConstructedResponse(props) {
17
+ var attributes = props.attributes,
18
+ value = props.value,
19
+ error = props.error;
20
+ return /*#__PURE__*/_react["default"].createElement("span", (0, _extends2["default"])({}, attributes, {
21
+ style: {
22
+ display: 'inline-flex',
23
+ visibility: props.isFocused ? 'hidden' : 'visible',
24
+ minHeight: '55px',
25
+ minWidth: '178px',
26
+ position: 'relative',
27
+ cursor: 'pointer'
28
+ }
29
+ }), /*#__PURE__*/_react["default"].createElement("div", {
30
+ style: {
31
+ display: 'inline-flex',
32
+ width: '100%',
33
+ minHeight: '46px',
34
+ height: '46px',
35
+ backgroundColor: '#FFF',
36
+ border: "1px solid ".concat(error ? 'red' : '#C0C3CF'),
37
+ boxSizing: 'border-box',
38
+ borderRadius: '4px',
39
+ overflow: 'hidden',
40
+ padding: '12px 21px',
41
+ marginLeft: '4px'
42
+ },
43
+ dangerouslySetInnerHTML: {
44
+ __html: value || '<div>&nbsp;</div>'
45
+ }
46
+ }));
47
+ };
48
+
49
+ ExplicitConstructedResponse.propTypes = {
50
+ attributes: _propTypes["default"].object,
51
+ error: _propTypes["default"].any,
52
+ value: _propTypes["default"].string,
53
+ isFocused: _propTypes["default"].bool
54
+ };
55
+ var _default = ExplicitConstructedResponse;
56
+ exports["default"] = _default;
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
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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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>&nbsp;</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"}
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.ToolbarIcon = exports.GripIcon = exports.Chevron = void 0;
9
+
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+
12
+ var _react = _interopRequireDefault(require("react"));
13
+
14
+ var _propTypes = _interopRequireDefault(require("prop-types"));
15
+
16
+ var _ChevronRight = _interopRequireDefault(require("@material-ui/icons/ChevronRight"));
17
+
18
+ var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
19
+
20
+ var _styles = require("@material-ui/core/styles");
21
+
22
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
23
+
24
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
25
+
26
+ var getRotate = function getRotate(direction) {
27
+ switch (direction) {
28
+ case 'down':
29
+ return 90;
30
+
31
+ case 'up':
32
+ return -90;
33
+
34
+ case 'left':
35
+ return 180;
36
+
37
+ default:
38
+ return 0;
39
+ }
40
+ };
41
+
42
+ var Chevron = function Chevron(props) {
43
+ var direction = props.direction,
44
+ style = props.style;
45
+ var rotate = getRotate(direction);
46
+ return /*#__PURE__*/_react["default"].createElement(_ChevronRight["default"], {
47
+ style: _objectSpread({
48
+ transform: "rotate(".concat(rotate, "deg)")
49
+ }, style)
50
+ });
51
+ };
52
+
53
+ exports.Chevron = Chevron;
54
+ Chevron.propTypes = {
55
+ direction: _propTypes["default"].string,
56
+ style: _propTypes["default"].object
57
+ };
58
+
59
+ var GripIcon = function GripIcon(_ref) {
60
+ var style = _ref.style;
61
+ return /*#__PURE__*/_react["default"].createElement("span", {
62
+ style: style
63
+ }, /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], {
64
+ style: {
65
+ margin: '0 -16px'
66
+ }
67
+ }), /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], null));
68
+ };
69
+
70
+ exports.GripIcon = GripIcon;
71
+ GripIcon.propTypes = {
72
+ style: _propTypes["default"].object
73
+ };
74
+ var ToolbarIcon = (0, _styles.withStyles)(function (theme) {
75
+ return {
76
+ icon: {
77
+ fontFamily: 'Cerebri Sans !important',
78
+ fontSize: theme.typography.fontSize,
79
+ fontWeight: 'bold',
80
+ lineHeight: '14px',
81
+ position: 'relative',
82
+ top: '7px',
83
+ width: '110px',
84
+ height: '28px',
85
+ whiteSpace: 'nowrap'
86
+ }
87
+ };
88
+ })(function (_ref2) {
89
+ var classes = _ref2.classes;
90
+ return /*#__PURE__*/_react["default"].createElement("div", {
91
+ className: classes.icon
92
+ }, "+ Response Area");
93
+ });
94
+ exports.ToolbarIcon = ToolbarIcon;
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/plugins/respArea/icons/index.jsx"],"names":["getRotate","direction","Chevron","props","style","rotate","transform","propTypes","PropTypes","string","object","GripIcon","margin","ToolbarIcon","theme","icon","fontFamily","fontSize","typography","fontWeight","lineHeight","position","top","width","height","whiteSpace","classes"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,SAAD,EAAe;AAC/B,UAAQA,SAAR;AACE,SAAK,MAAL;AACE,aAAO,EAAP;;AAEF,SAAK,IAAL;AACE,aAAO,CAAC,EAAR;;AAEF,SAAK,MAAL;AACE,aAAO,GAAP;;AAEF;AACE,aAAO,CAAP;AAXJ;AAaD,CAdD;;AAgBO,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAACC,KAAD,EAAW;AAChC,MAAQF,SAAR,GAA6BE,KAA7B,CAAQF,SAAR;AAAA,MAAmBG,KAAnB,GAA6BD,KAA7B,CAAmBC,KAAnB;AACA,MAAMC,MAAM,GAAGL,SAAS,CAACC,SAAD,CAAxB;AAEA,sBACE,gCAAC,wBAAD;AACE,IAAA,KAAK;AACHK,MAAAA,SAAS,mBAAYD,MAAZ;AADN,OAEAD,KAFA;AADP,IADF;AAQD,CAZM;;;AAcPF,OAAO,CAACK,SAAR,GAAoB;AAClBN,EAAAA,SAAS,EAAEO,sBAAUC,MADH;AAElBL,EAAAA,KAAK,EAAEI,sBAAUE;AAFC,CAApB;;AAKO,IAAMC,QAAQ,GAAG,SAAXA,QAAW,OAAe;AAAA,MAAZP,KAAY,QAAZA,KAAY;AACrC,sBACE;AAAM,IAAA,KAAK,EAAEA;AAAb,kBACE,gCAAC,oBAAD;AACE,IAAA,KAAK,EAAE;AACLQ,MAAAA,MAAM,EAAE;AADH;AADT,IADF,eAME,gCAAC,oBAAD,OANF,CADF;AAUD,CAXM;;;AAaPD,QAAQ,CAACJ,SAAT,GAAqB;AACnBH,EAAAA,KAAK,EAAEI,sBAAUE;AADE,CAArB;AAIO,IAAMG,WAAW,GAAG,wBAAW,UAACC,KAAD;AAAA,SAAY;AAChDC,IAAAA,IAAI,EAAE;AACJC,MAAAA,UAAU,EAAE,yBADR;AAEJC,MAAAA,QAAQ,EAAEH,KAAK,CAACI,UAAN,CAAiBD,QAFvB;AAGJE,MAAAA,UAAU,EAAE,MAHR;AAIJC,MAAAA,UAAU,EAAE,MAJR;AAKJC,MAAAA,QAAQ,EAAE,UALN;AAMJC,MAAAA,GAAG,EAAE,KAND;AAOJC,MAAAA,KAAK,EAAE,OAPH;AAQJC,MAAAA,MAAM,EAAE,MARJ;AASJC,MAAAA,UAAU,EAAE;AATR;AAD0C,GAAZ;AAAA,CAAX,EAYvB;AAAA,MAAGC,OAAH,SAAGA,OAAH;AAAA,sBAAiB;AAAK,IAAA,SAAS,EAAEA,OAAO,CAACX;AAAxB,uBAAjB;AAAA,CAZuB,CAApB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport ChevronRight from '@material-ui/icons/ChevronRight';\nimport MoreVert from '@material-ui/icons/MoreVert';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst getRotate = (direction) => {\n switch (direction) {\n case 'down':\n return 90;\n\n case 'up':\n return -90;\n\n case 'left':\n return 180;\n\n default:\n return 0;\n }\n};\n\nexport const Chevron = (props) => {\n const { direction, style } = props;\n const rotate = getRotate(direction);\n\n return (\n <ChevronRight\n style={{\n transform: `rotate(${rotate}deg)`,\n ...style,\n }}\n />\n );\n};\n\nChevron.propTypes = {\n direction: PropTypes.string,\n style: PropTypes.object,\n};\n\nexport const GripIcon = ({ style }) => {\n return (\n <span style={style}>\n <MoreVert\n style={{\n margin: '0 -16px',\n }}\n />\n <MoreVert />\n </span>\n );\n};\n\nGripIcon.propTypes = {\n style: PropTypes.object,\n};\n\nexport const ToolbarIcon = withStyles((theme) => ({\n icon: {\n fontFamily: 'Cerebri Sans !important',\n fontSize: theme.typography.fontSize,\n fontWeight: 'bold',\n lineHeight: '14px',\n position: 'relative',\n top: '7px',\n width: '110px',\n height: '28px',\n whiteSpace: 'nowrap',\n },\n}))(({ classes }) => <div className={classes.icon}>+ Response Area</div>);\n"],"file":"index.js"}
@@ -0,0 +1,341 @@
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"] = ResponseAreaPlugin;
9
+ exports.serialization = void 0;
10
+
11
+ var _react = _interopRequireDefault(require("react"));
12
+
13
+ var _debug = _interopRequireDefault(require("debug"));
14
+
15
+ var _isUndefined = _interopRequireDefault(require("lodash/isUndefined"));
16
+
17
+ var _inlineDropdown = _interopRequireDefault(require("./inline-dropdown"));
18
+
19
+ var _dragInTheBlank = _interopRequireDefault(require("./drag-in-the-blank"));
20
+
21
+ var _explicitConstructedResponse = _interopRequireDefault(require("./explicit-constructed-response"));
22
+
23
+ var _mathTemplated = _interopRequireDefault(require("./math-templated"));
24
+
25
+ var _utils = require("./utils");
26
+
27
+ var _icons = require("./icons");
28
+
29
+ var log = (0, _debug["default"])('@pie-lib:editable-html:plugins:respArea');
30
+ var lastIndexMap = {};
31
+ var elTypesMap = {
32
+ 'inline-dropdown': 'inline_dropdown',
33
+ 'explicit-constructed-response': 'explicit_constructed_response',
34
+ 'math-templated': 'math_templated',
35
+ 'drag-in-the-blank': 'drag_in_the_blank'
36
+ };
37
+ var elTypesArray = Object.values(elTypesMap);
38
+
39
+ function ResponseAreaPlugin(opts) {
40
+ var isOfCurrentType = function isOfCurrentType(d) {
41
+ return d.type === opts.type || d.type === elTypesMap[opts.type];
42
+ };
43
+
44
+ var toolbar = {
45
+ icon: /*#__PURE__*/_react["default"].createElement(_icons.ToolbarIcon, null),
46
+ buttonStyles: {
47
+ margin: '0 20px 0 auto'
48
+ },
49
+ onClick: function onClick(value, onChange) {
50
+ log('[toolbar] onClick');
51
+ var change = value.change();
52
+ var currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);
53
+
54
+ if (currentRespAreaList.size >= opts.maxResponseAreas) {
55
+ return;
56
+ }
57
+
58
+ var type = opts.type.replace(/-/g, '_');
59
+ var prevIndex = lastIndexMap[type];
60
+ var newIndex = prevIndex === 0 ? prevIndex : prevIndex + 1;
61
+ var newInline = (0, _utils.getDefaultElement)(opts, newIndex);
62
+ lastIndexMap[type] += 1;
63
+
64
+ if (newInline) {
65
+ if (change.value.selection.startKey || change.value.selection.endKey) {
66
+ change.insertInline(newInline);
67
+ } else {
68
+ // If the markup is empty and there's no focus
69
+ var lastText = value.document.getLastText();
70
+
71
+ if (!lastText) {
72
+ return;
73
+ }
74
+
75
+ var parentNode = value.document.getParent(lastText.key);
76
+
77
+ if (parentNode) {
78
+ var index = parentNode.nodes.indexOf(lastText.key);
79
+ if (parentNode.isVoid) return;
80
+ change.insertNodeByKey(parentNode.key, index + 1, newInline);
81
+ }
82
+ }
83
+
84
+ if (newInline.type === 'drag_in_the_blank') {
85
+ var nextText = change.value.document.getNextText(newInline.key);
86
+
87
+ if (nextText) {
88
+ change.moveFocusTo(nextText.key, 0).moveAnchorTo(nextText.key, 0);
89
+ }
90
+ }
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
+
100
+ onChange(change);
101
+ }
102
+ },
103
+ customToolbar: opts.respAreaToolbar,
104
+ supports: function supports(node) {
105
+ return node.object === 'inline' && elTypesArray.indexOf(node.type) >= 0;
106
+ },
107
+ showDone: false
108
+ };
109
+ return {
110
+ name: 'response_area',
111
+ toolbar: toolbar,
112
+ filterPlugins: function filterPlugins(node, plugins) {
113
+ if (node.type === 'explicit_constructed_response' || node.type === 'math_templated' || node.type === 'drag_in_the_blank') {
114
+ return [];
115
+ }
116
+
117
+ return plugins.filter(function (p) {
118
+ return p.name !== 'response_area';
119
+ });
120
+ },
121
+ deleteNode: function deleteNode(e, node, value, onChange) {
122
+ e.preventDefault();
123
+ var change = value.change().removeNodeByKey(node.key);
124
+ onChange(change);
125
+ },
126
+ renderNode: function renderNode(props) {
127
+ var attributes = props.attributes,
128
+ n = props.node,
129
+ isFocused = props.isFocused;
130
+
131
+ if (n.type === 'explicit_constructed_response') {
132
+ var data = n.data.toJSON();
133
+ var error;
134
+
135
+ if (opts.error) {
136
+ error = opts.error();
137
+ }
138
+
139
+ return /*#__PURE__*/_react["default"].createElement(_explicitConstructedResponse["default"], {
140
+ attributes: attributes,
141
+ isFocused: isFocused,
142
+ value: data.value,
143
+ error: error && error[data.index] && error[data.index][0]
144
+ });
145
+ }
146
+
147
+ if (n.type === 'math_templated') {
148
+ var _data = n.data.toJSON();
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
+
169
+ return /*#__PURE__*/_react["default"].createElement(_dragInTheBlank["default"], {
170
+ attributes: attributes,
171
+ data: _data2,
172
+ n: n,
173
+ nodeProps: props,
174
+ opts: opts
175
+ });
176
+ }
177
+
178
+ if (n.type === 'inline_dropdown') {
179
+ var _data3 = n.data.toJSON();
180
+
181
+ return /*#__PURE__*/_react["default"].createElement(_inlineDropdown["default"], {
182
+ attributes: attributes,
183
+ selectedItem: _data3.value
184
+ });
185
+ }
186
+ },
187
+ onChange: function onChange(change, editor) {
188
+ var type = opts.type.replace(/-/g, '_');
189
+
190
+ if ((0, _isUndefined["default"])(lastIndexMap[type])) {
191
+ lastIndexMap[type] = 0;
192
+ change.value.document.forEachDescendant(function (d) {
193
+ if (d.type === type) {
194
+ var newIndex = parseInt(d.data.get('index'), 10);
195
+
196
+ if (newIndex > lastIndexMap[type]) {
197
+ lastIndexMap[type] = newIndex;
198
+ }
199
+ }
200
+ });
201
+ }
202
+
203
+ if (!editor.value) {
204
+ return;
205
+ }
206
+
207
+ var currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);
208
+ var oldRespAreaList = editor.value.document.filterDescendants(isOfCurrentType);
209
+ toolbar.disabled = currentRespAreaList.size >= opts.maxResponseAreas;
210
+ var arrayToFilter = oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;
211
+ var arrayToUseForFilter = arrayToFilter === oldRespAreaList ? currentRespAreaList : oldRespAreaList;
212
+ var elementsWithChangedStatus = arrayToFilter.filter(function (d) {
213
+ return !arrayToUseForFilter.find(function (e) {
214
+ return e.data.get('index') === d.data.get('index');
215
+ });
216
+ });
217
+
218
+ if (elementsWithChangedStatus.size && oldRespAreaList.size > currentRespAreaList.size) {
219
+ opts.onHandleAreaChange(elementsWithChangedStatus);
220
+ }
221
+ },
222
+ onDrop: function onDrop(event, change, editor) {
223
+ var closestEl = event.target.closest('[data-key]');
224
+ var inline = editor.value.document.findDescendant(function (d) {
225
+ return d.key === closestEl.dataset.key;
226
+ });
227
+
228
+ if (inline.type === 'drag_in_the_blank') {
229
+ return false;
230
+ }
231
+ }
232
+ };
233
+ }
234
+
235
+ var serialization = {
236
+ deserialize: function deserialize(el) {
237
+ var type = el.dataset && el.dataset.type;
238
+
239
+ switch (type) {
240
+ case 'inline_dropdown':
241
+ return {
242
+ object: 'inline',
243
+ type: 'inline_dropdown',
244
+ isVoid: true,
245
+ data: {
246
+ index: el.dataset.index,
247
+ value: el.dataset.value
248
+ }
249
+ };
250
+
251
+ case 'explicit_constructed_response':
252
+ return {
253
+ object: 'inline',
254
+ type: 'explicit_constructed_response',
255
+ isVoid: true,
256
+ data: {
257
+ index: el.dataset.index,
258
+ value: el.dataset.value
259
+ }
260
+ };
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
+
273
+ case 'drag_in_the_blank':
274
+ return {
275
+ object: 'inline',
276
+ type: 'drag_in_the_blank',
277
+ isVoid: true,
278
+ data: {
279
+ index: el.dataset.index,
280
+ id: el.dataset.id,
281
+ value: el.dataset.value,
282
+ inTable: el.dataset.inTable
283
+ }
284
+ };
285
+ }
286
+ },
287
+ serialize: function serialize(object) {
288
+ if (object.object !== 'inline') {
289
+ return;
290
+ }
291
+
292
+ switch (object.type) {
293
+ case 'inline_dropdown':
294
+ {
295
+ var data = object.data.toJSON();
296
+ return /*#__PURE__*/_react["default"].createElement("span", {
297
+ "data-type": "inline_dropdown",
298
+ "data-index": data.index,
299
+ "data-value": data.value
300
+ });
301
+ }
302
+
303
+ case 'explicit_constructed_response':
304
+ {
305
+ var _data4 = object.data.toJSON();
306
+
307
+ return /*#__PURE__*/_react["default"].createElement("span", {
308
+ "data-type": "explicit_constructed_response",
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
322
+ });
323
+ }
324
+
325
+ case 'drag_in_the_blank':
326
+ {
327
+ var _data6 = object.data.toJSON();
328
+
329
+ return /*#__PURE__*/_react["default"].createElement("span", {
330
+ "data-type": "drag_in_the_blank",
331
+ "data-index": _data6.index,
332
+ "data-id": _data6.id,
333
+ "data-value": _data6.value,
334
+ "data-in-table": _data6.inTable
335
+ });
336
+ }
337
+ }
338
+ }
339
+ };
340
+ exports.serialization = serialization;
341
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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","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,mCAAiC,+BAFhB;AAGjB,oBAAkB,gBAHD;AAIjB,uBAAqB;AAJJ,CAAnB;AAMA,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcH,UAAd,CAArB;;AAEe,SAASI,kBAAT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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"}