@pie-lib/editable-html 7.17.4-next.373 → 7.17.4-next.406
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/lib/editor.js +119 -107
- package/lib/editor.js.map +1 -1
- package/lib/index.js +30 -42
- package/lib/index.js.map +1 -1
- package/lib/plugins/characters/custom-popover.js +8 -11
- package/lib/plugins/characters/custom-popover.js.map +1 -1
- package/lib/plugins/characters/index.js +8 -18
- package/lib/plugins/characters/index.js.map +1 -1
- package/lib/plugins/image/component.js +65 -54
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +65 -27
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +47 -12
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +8 -12
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +6 -15
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +2 -2
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +8 -8
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +15 -20
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +26 -41
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +15 -25
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +22 -35
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +24 -37
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +8 -8
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +5 -5
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +5 -5
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +2 -2
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +5 -5
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +2 -2
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js +9 -9
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +11 -11
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +25 -36
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +5 -5
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +2 -2
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +18 -30
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +5 -5
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +25 -43
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +30 -49
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/serialization.js +2 -2
- package/lib/serialization.js.map +1 -1
- package/package.json +3 -3
- package/src/editor.jsx +25 -25
- package/src/plugins/image/component.jsx +49 -20
- package/src/plugins/image/image-toolbar.jsx +37 -2
- package/src/plugins/image/index.jsx +38 -9
|
@@ -1,52 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
17
|
|
|
18
|
-
var
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
|
-
|
|
30
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
31
|
-
|
|
32
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
33
27
|
|
|
34
|
-
|
|
28
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
35
29
|
|
|
36
|
-
|
|
30
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
37
31
|
|
|
38
|
-
|
|
32
|
+
var _styles = require("@material-ui/core/styles");
|
|
39
33
|
|
|
40
|
-
|
|
34
|
+
var _excluded = ["editor", "classes", "children", "width"];
|
|
41
35
|
|
|
42
|
-
function
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
43
37
|
|
|
44
38
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
45
39
|
|
|
46
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
47
|
-
|
|
48
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
49
|
-
|
|
50
40
|
var useStyles = (0, _styles.withStyles)(function () {
|
|
51
41
|
return {
|
|
52
42
|
root: {
|
|
@@ -60,17 +50,16 @@ var useStyles = (0, _styles.withStyles)(function () {
|
|
|
60
50
|
});
|
|
61
51
|
|
|
62
52
|
var MediaWrapper = /*#__PURE__*/function (_React$Component) {
|
|
63
|
-
|
|
53
|
+
(0, _inherits2["default"])(MediaWrapper, _React$Component);
|
|
64
54
|
|
|
65
55
|
var _super = _createSuper(MediaWrapper);
|
|
66
56
|
|
|
67
57
|
function MediaWrapper() {
|
|
68
|
-
|
|
69
|
-
|
|
58
|
+
(0, _classCallCheck2["default"])(this, MediaWrapper);
|
|
70
59
|
return _super.apply(this, arguments);
|
|
71
60
|
}
|
|
72
61
|
|
|
73
|
-
|
|
62
|
+
(0, _createClass2["default"])(MediaWrapper, [{
|
|
74
63
|
key: "render",
|
|
75
64
|
value: function render() {
|
|
76
65
|
var _this$props = this.props,
|
|
@@ -78,10 +67,9 @@ var MediaWrapper = /*#__PURE__*/function (_React$Component) {
|
|
|
78
67
|
classes = _this$props.classes,
|
|
79
68
|
children = _this$props.children,
|
|
80
69
|
width = _this$props.width,
|
|
81
|
-
rest =
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
className: (0, _classnames["default"])(classes.root, _defineProperty({}, classes.editor, editor))
|
|
70
|
+
rest = (0, _objectWithoutProperties2["default"])(_this$props, _excluded);
|
|
71
|
+
return /*#__PURE__*/_react["default"].createElement("span", (0, _extends2["default"])({
|
|
72
|
+
className: (0, _classnames["default"])(classes.root, (0, _defineProperty2["default"])({}, classes.editor, editor))
|
|
85
73
|
}, rest, {
|
|
86
74
|
style: {
|
|
87
75
|
width: width || 300
|
|
@@ -89,11 +77,10 @@ var MediaWrapper = /*#__PURE__*/function (_React$Component) {
|
|
|
89
77
|
}), children);
|
|
90
78
|
}
|
|
91
79
|
}]);
|
|
92
|
-
|
|
93
80
|
return MediaWrapper;
|
|
94
81
|
}(_react["default"].Component);
|
|
95
82
|
|
|
96
|
-
|
|
83
|
+
(0, _defineProperty2["default"])(MediaWrapper, "propTypes", {
|
|
97
84
|
classes: _propTypes["default"].object,
|
|
98
85
|
children: _propTypes["default"].array,
|
|
99
86
|
editor: _propTypes["default"].bool,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"media-wrapper.js","names":["useStyles","withStyles","root","position","editor","display","overflow","MediaWrapper","props","classes","children","width","rest","classNames","React","Component","PropTypes","object","array","bool","oneOfType","number","string"],"sources":["../../../src/plugins/media/media-wrapper.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst useStyles = withStyles(() => ({\n root: {\n position: 'relative'\n },\n editor: {\n display: 'inline-block',\n overflow: 'hidden'\n }\n}));\n\nclass MediaWrapper extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n children: PropTypes.array,\n editor: PropTypes.bool,\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n };\n\n render() {\n const { editor, classes, children, width, ...rest } = this.props;\n\n return (\n <span\n className={classNames(classes.root, {\n [classes.editor]: editor\n })}\n {...rest}\n style={{\n width: width || 300\n }}\n >\n {children}\n </span>\n );\n }\n}\n\nexport default useStyles(MediaWrapper);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"media-wrapper.js","names":["useStyles","withStyles","root","position","editor","display","overflow","MediaWrapper","props","classes","children","width","rest","classNames","React","Component","PropTypes","object","array","bool","oneOfType","number","string"],"sources":["../../../src/plugins/media/media-wrapper.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport classNames from 'classnames';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst useStyles = withStyles(() => ({\n root: {\n position: 'relative'\n },\n editor: {\n display: 'inline-block',\n overflow: 'hidden'\n }\n}));\n\nclass MediaWrapper extends React.Component {\n static propTypes = {\n classes: PropTypes.object,\n children: PropTypes.array,\n editor: PropTypes.bool,\n width: PropTypes.oneOfType([PropTypes.number, PropTypes.string])\n };\n\n render() {\n const { editor, classes, children, width, ...rest } = this.props;\n\n return (\n <span\n className={classNames(classes.root, {\n [classes.editor]: editor\n })}\n {...rest}\n style={{\n width: width || 300\n }}\n >\n {children}\n </span>\n );\n }\n}\n\nexport default useStyles(MediaWrapper);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,SAAS,GAAG,IAAAC,kBAAA,EAAW;EAAA,OAAO;IAClCC,IAAI,EAAE;MACJC,QAAQ,EAAE;IADN,CAD4B;IAIlCC,MAAM,EAAE;MACNC,OAAO,EAAE,cADH;MAENC,QAAQ,EAAE;IAFJ;EAJ0B,CAAP;AAAA,CAAX,CAAlB;;IAUMC,Y;;;;;;;;;;;;WAQJ,kBAAS;MACP,kBAAsD,KAAKC,KAA3D;MAAA,IAAQJ,MAAR,eAAQA,MAAR;MAAA,IAAgBK,OAAhB,eAAgBA,OAAhB;MAAA,IAAyBC,QAAzB,eAAyBA,QAAzB;MAAA,IAAmCC,KAAnC,eAAmCA,KAAnC;MAAA,IAA6CC,IAA7C;MAEA,oBACE;QACE,SAAS,EAAE,IAAAC,sBAAA,EAAWJ,OAAO,CAACP,IAAnB,uCACRO,OAAO,CAACL,MADA,EACSA,MADT;MADb,GAIMQ,IAJN;QAKE,KAAK,EAAE;UACLD,KAAK,EAAEA,KAAK,IAAI;QADX;MALT,IASGD,QATH,CADF;IAaD;;;EAxBwBI,iBAAA,CAAMC,S;;iCAA3BR,Y,eACe;EACjBE,OAAO,EAAEO,qBAAA,CAAUC,MADF;EAEjBP,QAAQ,EAAEM,qBAAA,CAAUE,KAFH;EAGjBd,MAAM,EAAEY,qBAAA,CAAUG,IAHD;EAIjBR,KAAK,EAAEK,qBAAA,CAAUI,SAAV,CAAoB,CAACJ,qBAAA,CAAUK,MAAX,EAAmBL,qBAAA,CAAUM,MAA7B,CAApB;AAJU,C;;eA0BNtB,SAAS,CAACO,YAAD,C"}
|
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
8
|
exports.tileTarget = exports.tileSource = exports["default"] = exports.BlankContent = void 0;
|
|
9
9
|
|
|
10
|
+
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
10
26
|
var _react = _interopRequireDefault(require("react"));
|
|
11
27
|
|
|
12
28
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -27,34 +43,10 @@ var _icons = require("../icons");
|
|
|
27
43
|
|
|
28
44
|
var _excluded = ["connectDropTarget", "connectDragSource"];
|
|
29
45
|
|
|
30
|
-
function
|
|
31
|
-
|
|
32
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
33
|
-
|
|
34
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
35
|
-
|
|
36
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
37
|
-
|
|
38
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
39
|
-
|
|
40
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
41
|
-
|
|
42
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
43
|
-
|
|
44
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
45
|
-
|
|
46
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
47
|
-
|
|
48
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
49
|
-
|
|
50
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
46
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2["default"])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2["default"])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2["default"])(this, result); }; }
|
|
51
47
|
|
|
52
48
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
53
49
|
|
|
54
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
55
|
-
|
|
56
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
57
|
-
|
|
58
50
|
var useStyles = (0, _styles.withStyles)(function (theme) {
|
|
59
51
|
return {
|
|
60
52
|
content: {
|
|
@@ -76,21 +68,20 @@ var useStyles = (0, _styles.withStyles)(function (theme) {
|
|
|
76
68
|
});
|
|
77
69
|
|
|
78
70
|
var BlankContent = /*#__PURE__*/function (_React$Component) {
|
|
79
|
-
|
|
71
|
+
(0, _inherits2["default"])(BlankContent, _React$Component);
|
|
80
72
|
|
|
81
73
|
var _super = _createSuper(BlankContent);
|
|
82
74
|
|
|
83
75
|
function BlankContent(props) {
|
|
84
76
|
var _this;
|
|
85
77
|
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
(0, _classCallCheck2["default"])(this, BlankContent);
|
|
88
79
|
_this = _super.call(this, props);
|
|
89
|
-
_this.handleClick = _this.handleClick.bind(
|
|
80
|
+
_this.handleClick = _this.handleClick.bind((0, _assertThisInitialized2["default"])(_this));
|
|
90
81
|
return _this;
|
|
91
82
|
}
|
|
92
83
|
|
|
93
|
-
|
|
84
|
+
(0, _createClass2["default"])(BlankContent, [{
|
|
94
85
|
key: "componentDidMount",
|
|
95
86
|
value: function componentDidMount() {
|
|
96
87
|
document.addEventListener('click', this.handleClick);
|
|
@@ -164,13 +155,11 @@ var BlankContent = /*#__PURE__*/function (_React$Component) {
|
|
|
164
155
|
}), children);
|
|
165
156
|
}
|
|
166
157
|
}]);
|
|
167
|
-
|
|
168
158
|
return BlankContent;
|
|
169
159
|
}(_react["default"].Component);
|
|
170
160
|
|
|
171
161
|
exports.BlankContent = BlankContent;
|
|
172
|
-
|
|
173
|
-
_defineProperty(BlankContent, "propTypes", {
|
|
162
|
+
(0, _defineProperty2["default"])(BlankContent, "propTypes", {
|
|
174
163
|
n: _propTypes["default"].object,
|
|
175
164
|
children: _propTypes["default"].func,
|
|
176
165
|
isDragging: _propTypes["default"].bool,
|
|
@@ -179,13 +168,11 @@ _defineProperty(BlankContent, "propTypes", {
|
|
|
179
168
|
value: _propTypes["default"].object,
|
|
180
169
|
classes: _propTypes["default"].object
|
|
181
170
|
});
|
|
182
|
-
|
|
183
171
|
var StyledBlankContent = useStyles(BlankContent);
|
|
184
172
|
var connectedBlankContent = useStyles(function (_ref2) {
|
|
185
173
|
var connectDropTarget = _ref2.connectDropTarget,
|
|
186
174
|
connectDragSource = _ref2.connectDragSource,
|
|
187
|
-
props =
|
|
188
|
-
|
|
175
|
+
props = (0, _objectWithoutProperties2["default"])(_ref2, _excluded);
|
|
189
176
|
var classes = props.classes,
|
|
190
177
|
isOver = props.isOver,
|
|
191
178
|
value = props.value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choice.js","names":["useStyles","withStyles","theme","content","border","palette","primary","main","chip","minWidth","correct","incorrect","selected","color","primaryDark","BlankContent","props","handleClick","bind","document","addEventListener","removeEventListener","event","classes","elementRef","className","contains","target","renderMath","n","children","isDragging","dragItem","isOver","value","label","finalLabel","hasGrip","ref","display","minHeight","background","boxSizing","borderRadius","overflow","position","padding","key","top","left","__html","React","Component","PropTypes","object","func","bool","StyledBlankContent","connectedBlankContent","connectDropTarget","connectDragSource","dragContent","dragEl","classnames","over","tileTarget","drop","monitor","draggedItem","getItem","shouldDrop","isUndefined","index","onChange","dropped","canDrop","instanceId","DropTile","DropTarget","connect","dropTarget","tileSource","canDrag","disabled","beginDrag","id","targetId","fromChoice","endDrag","dropResult","getDropResult","duplicates","removeResponse","DragSource","dragSource"],"sources":["../../../../src/plugins/respArea/drag-in-the-blank/choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isUndefined from 'lodash/isUndefined';\nimport { DragSource, DropTarget } from '@pie-lib/drag';\nimport { color } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { withStyles } from '@material-ui/core/styles';\nimport classnames from 'classnames';\n\nimport { GripIcon } from '../icons';\n\nconst useStyles = withStyles(theme => ({\n content: {\n border: `solid 0px ${theme.palette.primary.main}`\n },\n chip: {\n minWidth: '90px'\n },\n correct: {\n border: 'solid 1px green'\n },\n incorrect: {\n border: 'solid 1px red'\n },\n selected: {\n border: `2px solid ${color.primaryDark()} !important`\n }\n}));\n\nexport class BlankContent extends React.Component {\n static propTypes = {\n n: PropTypes.object,\n children: PropTypes.func,\n isDragging: PropTypes.bool,\n isOver: PropTypes.bool,\n dragItem: PropTypes.object,\n value: PropTypes.object,\n classes: PropTypes.object\n };\n\n constructor(props) {\n super(props);\n\n this.handleClick = this.handleClick.bind(this);\n }\n\n componentDidMount() {\n document.addEventListener('click', this.handleClick);\n }\n\n componentWillUnmount() {\n document.removeEventListener('click', this.handleClick);\n }\n\n handleClick(event) {\n const { classes } = this.props;\n\n if (this.elementRef) {\n this.elementRef.className = this.elementRef.contains(event.target) ? classes.selected : '';\n }\n }\n\n componentDidUpdate() {\n if (this.elementRef) {\n renderMath(this.elementRef);\n }\n }\n\n render() {\n const { n, children, isDragging, dragItem, isOver, value } = this.props;\n\n const label = dragItem && isOver ? dragItem.value.value : value.value || '\\u00A0';\n const finalLabel = isDragging ? '\\u00A0' : label;\n const hasGrip = finalLabel !== '\\u00A0';\n\n return (\n <div\n ref={ref => (this.elementRef = ref)}\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n background: '#FFF',\n border: '1px solid #C0C3CF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n position: 'relative',\n padding: '8px 8px 8px 35px'\n }}\n data-key={n.key}\n contentEditable={false}\n >\n {hasGrip && (\n <GripIcon\n style={{\n position: 'absolute',\n top: '6px',\n left: '15px',\n color: '#9B9B9B'\n }}\n contentEditable={false}\n />\n )}\n <span\n dangerouslySetInnerHTML={{\n __html: finalLabel\n }}\n />\n {children}\n </div>\n );\n }\n}\n\nconst StyledBlankContent = useStyles(BlankContent);\n\nconst connectedBlankContent = useStyles(({ connectDropTarget, connectDragSource, ...props }) => {\n const { classes, isOver, value } = props;\n const dragContent = <StyledBlankContent {...props} />;\n const dragEl = !value ? dragContent : connectDragSource(<span>{dragContent}</span>);\n const content = (\n <span className={classnames(classes.content, isOver && classes.over)}>{dragEl}</span>\n );\n\n return connectDropTarget ? connectDropTarget(content) : content;\n});\n\nexport const tileTarget = {\n drop(props, monitor) {\n const draggedItem = monitor.getItem();\n const shouldDrop =\n isUndefined(draggedItem.value.index) ||\n isUndefined(props.value.index) ||\n draggedItem.value.index !== props.value.index;\n\n if (shouldDrop) {\n props.onChange(draggedItem.value);\n }\n\n return {\n dropped: shouldDrop\n };\n },\n canDrop(props, monitor) {\n const draggedItem = monitor.getItem();\n\n return draggedItem.instanceId === props.instanceId;\n }\n};\n\nconst DropTile = DropTarget('drag-in-the-blank-choice', tileTarget, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver(),\n dragItem: monitor.getItem()\n}))(connectedBlankContent);\n\nexport const tileSource = {\n canDrag(props) {\n return !props.disabled && !!props.value;\n },\n beginDrag(props) {\n return {\n id: props.targetId,\n value: props.value,\n instanceId: props.instanceId,\n fromChoice: true\n };\n },\n endDrag(props, monitor) {\n // this will be null if it did not drop\n const dropResult = monitor.getDropResult();\n\n if (!dropResult || (dropResult.dropped && !props.duplicates)) {\n const draggedItem = monitor.getItem();\n\n if (draggedItem.fromChoice) {\n props.removeResponse(draggedItem.value);\n }\n }\n }\n};\n\nexport default DragSource('drag-in-the-blank-choice', tileSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging()\n}))(DropTile);\n"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,IAAAC,kBAAA,EAAW,UAAAC,KAAK;EAAA,OAAK;IACrCC,OAAO,EAAE;MACPC,MAAM,sBAAeF,KAAK,CAACG,OAAN,CAAcC,OAAd,CAAsBC,IAArC;IADC,CAD4B;IAIrCC,IAAI,EAAE;MACJC,QAAQ,EAAE;IADN,CAJ+B;IAOrCC,OAAO,EAAE;MACPN,MAAM,EAAE;IADD,CAP4B;IAUrCO,SAAS,EAAE;MACTP,MAAM,EAAE;IADC,CAV0B;IAarCQ,QAAQ,EAAE;MACRR,MAAM,sBAAeS,eAAA,CAAMC,WAAN,EAAf;IADE;EAb2B,CAAL;AAAA,CAAhB,CAAlB;;IAkBaC,Y;;;;;EAWX,sBAAYC,KAAZ,EAAmB;IAAA;;IAAA;;IACjB,0BAAMA,KAAN;IAEA,MAAKC,WAAL,GAAmB,MAAKA,WAAL,CAAiBC,IAAjB,+BAAnB;IAHiB;EAIlB;;;;WAED,6BAAoB;MAClBC,QAAQ,CAAC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withStyles","theme","content","border","palette","primary","main","chip","minWidth","correct","incorrect","selected","color","primaryDark","BlankContent","props","handleClick","bind","document","addEventListener","removeEventListener","event","classes","elementRef","className","contains","target","renderMath","n","children","isDragging","dragItem","isOver","value","label","finalLabel","hasGrip","ref","display","minHeight","background","boxSizing","borderRadius","overflow","position","padding","key","top","left","__html","React","Component","PropTypes","object","func","bool","StyledBlankContent","connectedBlankContent","connectDropTarget","connectDragSource","dragContent","dragEl","classnames","over","tileTarget","drop","monitor","draggedItem","getItem","shouldDrop","isUndefined","index","onChange","dropped","canDrop","instanceId","DropTile","DropTarget","connect","dropTarget","tileSource","canDrag","disabled","beginDrag","id","targetId","fromChoice","endDrag","dropResult","getDropResult","duplicates","removeResponse","DragSource","dragSource"],"sources":["../../../../src/plugins/respArea/drag-in-the-blank/choice.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport isUndefined from 'lodash/isUndefined';\nimport { DragSource, DropTarget } from '@pie-lib/drag';\nimport { color } from '@pie-lib/render-ui';\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { withStyles } from '@material-ui/core/styles';\nimport classnames from 'classnames';\n\nimport { GripIcon } from '../icons';\n\nconst useStyles = withStyles(theme => ({\n content: {\n border: `solid 0px ${theme.palette.primary.main}`\n },\n chip: {\n minWidth: '90px'\n },\n correct: {\n border: 'solid 1px green'\n },\n incorrect: {\n border: 'solid 1px red'\n },\n selected: {\n border: `2px solid ${color.primaryDark()} !important`\n }\n}));\n\nexport class BlankContent extends React.Component {\n static propTypes = {\n n: PropTypes.object,\n children: PropTypes.func,\n isDragging: PropTypes.bool,\n isOver: PropTypes.bool,\n dragItem: PropTypes.object,\n value: PropTypes.object,\n classes: PropTypes.object\n };\n\n constructor(props) {\n super(props);\n\n this.handleClick = this.handleClick.bind(this);\n }\n\n componentDidMount() {\n document.addEventListener('click', this.handleClick);\n }\n\n componentWillUnmount() {\n document.removeEventListener('click', this.handleClick);\n }\n\n handleClick(event) {\n const { classes } = this.props;\n\n if (this.elementRef) {\n this.elementRef.className = this.elementRef.contains(event.target) ? classes.selected : '';\n }\n }\n\n componentDidUpdate() {\n if (this.elementRef) {\n renderMath(this.elementRef);\n }\n }\n\n render() {\n const { n, children, isDragging, dragItem, isOver, value } = this.props;\n\n const label = dragItem && isOver ? dragItem.value.value : value.value || '\\u00A0';\n const finalLabel = isDragging ? '\\u00A0' : label;\n const hasGrip = finalLabel !== '\\u00A0';\n\n return (\n <div\n ref={ref => (this.elementRef = ref)}\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n background: '#FFF',\n border: '1px solid #C0C3CF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n position: 'relative',\n padding: '8px 8px 8px 35px'\n }}\n data-key={n.key}\n contentEditable={false}\n >\n {hasGrip && (\n <GripIcon\n style={{\n position: 'absolute',\n top: '6px',\n left: '15px',\n color: '#9B9B9B'\n }}\n contentEditable={false}\n />\n )}\n <span\n dangerouslySetInnerHTML={{\n __html: finalLabel\n }}\n />\n {children}\n </div>\n );\n }\n}\n\nconst StyledBlankContent = useStyles(BlankContent);\n\nconst connectedBlankContent = useStyles(({ connectDropTarget, connectDragSource, ...props }) => {\n const { classes, isOver, value } = props;\n const dragContent = <StyledBlankContent {...props} />;\n const dragEl = !value ? dragContent : connectDragSource(<span>{dragContent}</span>);\n const content = (\n <span className={classnames(classes.content, isOver && classes.over)}>{dragEl}</span>\n );\n\n return connectDropTarget ? connectDropTarget(content) : content;\n});\n\nexport const tileTarget = {\n drop(props, monitor) {\n const draggedItem = monitor.getItem();\n const shouldDrop =\n isUndefined(draggedItem.value.index) ||\n isUndefined(props.value.index) ||\n draggedItem.value.index !== props.value.index;\n\n if (shouldDrop) {\n props.onChange(draggedItem.value);\n }\n\n return {\n dropped: shouldDrop\n };\n },\n canDrop(props, monitor) {\n const draggedItem = monitor.getItem();\n\n return draggedItem.instanceId === props.instanceId;\n }\n};\n\nconst DropTile = DropTarget('drag-in-the-blank-choice', tileTarget, (connect, monitor) => ({\n connectDropTarget: connect.dropTarget(),\n isOver: monitor.isOver(),\n dragItem: monitor.getItem()\n}))(connectedBlankContent);\n\nexport const tileSource = {\n canDrag(props) {\n return !props.disabled && !!props.value;\n },\n beginDrag(props) {\n return {\n id: props.targetId,\n value: props.value,\n instanceId: props.instanceId,\n fromChoice: true\n };\n },\n endDrag(props, monitor) {\n // this will be null if it did not drop\n const dropResult = monitor.getDropResult();\n\n if (!dropResult || (dropResult.dropped && !props.duplicates)) {\n const draggedItem = monitor.getItem();\n\n if (draggedItem.fromChoice) {\n props.removeResponse(draggedItem.value);\n }\n }\n }\n};\n\nexport default DragSource('drag-in-the-blank-choice', tileSource, (connect, monitor) => ({\n connectDragSource: connect.dragSource(),\n isDragging: monitor.isDragging()\n}))(DropTile);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;AAEA,IAAMA,SAAS,GAAG,IAAAC,kBAAA,EAAW,UAAAC,KAAK;EAAA,OAAK;IACrCC,OAAO,EAAE;MACPC,MAAM,sBAAeF,KAAK,CAACG,OAAN,CAAcC,OAAd,CAAsBC,IAArC;IADC,CAD4B;IAIrCC,IAAI,EAAE;MACJC,QAAQ,EAAE;IADN,CAJ+B;IAOrCC,OAAO,EAAE;MACPN,MAAM,EAAE;IADD,CAP4B;IAUrCO,SAAS,EAAE;MACTP,MAAM,EAAE;IADC,CAV0B;IAarCQ,QAAQ,EAAE;MACRR,MAAM,sBAAeS,eAAA,CAAMC,WAAN,EAAf;IADE;EAb2B,CAAL;AAAA,CAAhB,CAAlB;;IAkBaC,Y;;;;;EAWX,sBAAYC,KAAZ,EAAmB;IAAA;;IAAA;IACjB,0BAAMA,KAAN;IAEA,MAAKC,WAAL,GAAmB,MAAKA,WAAL,CAAiBC,IAAjB,gDAAnB;IAHiB;EAIlB;;;;WAED,6BAAoB;MAClBC,QAAQ,C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ict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.onValueChange = exports.onRemoveResponse = exports["default"] = void 0;
|
|
7
9
|
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
|
|
8
14
|
var _react = _interopRequireDefault(require("react"));
|
|
9
15
|
|
|
10
16
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
17
|
|
|
12
18
|
var _choice = _interopRequireDefault(require("./choice"));
|
|
13
19
|
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
|
|
16
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
17
|
-
|
|
18
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; }
|
|
19
21
|
|
|
20
|
-
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) {
|
|
21
|
-
|
|
22
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
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
23
|
|
|
24
24
|
var onValueChange = function onValueChange(nodeProps, n, value) {
|
|
25
25
|
var val = nodeProps.editor.value;
|
|
@@ -61,7 +61,7 @@ var DragDrop = function DragDrop(props) {
|
|
|
61
61
|
nodeProps = props.nodeProps,
|
|
62
62
|
opts = props.opts;
|
|
63
63
|
var inTable = data.inTable;
|
|
64
|
-
return /*#__PURE__*/_react["default"].createElement("span",
|
|
64
|
+
return /*#__PURE__*/_react["default"].createElement("span", (0, _extends2["default"])({}, attributes, {
|
|
65
65
|
style: {
|
|
66
66
|
display: 'inline-flex',
|
|
67
67
|
minHeight: '50px',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","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"],"sources":["../../../../src/plugins/respArea/drag-in-the-blank/index.jsx"],"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 => n.data && n.data.get('index') === value.index\n );\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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","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"],"sources":["../../../../src/plugins/respArea/drag-in-the-blank/index.jsx"],"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 => n.data && n.data.get('index') === value.index\n );\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"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;;;;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,SAAD,EAAYC,CAAZ,EAAeC,KAAf,EAAyB;EACpD,IAAMC,GAAG,GAAGH,SAAS,CAACI,MAAV,CAAiBF,KAA7B;EACA,IAAMG,MAAM,GAAGF,GAAG,CAACE,MAAJ,EAAf;EAEAA,MAAM,CAACC,YAAP,CAAoBL,CAAC,CAACM,GAAtB,EAA2B;IACzBC,IAAI,kCACCN,KADD;MAEFO,KAAK,EAAER,CAAC,CAACO,IAAF,CAAOE,GAAP,CAAW,OAAX;IAFL;EADqB,CAA3B;EAOAV,SAAS,CAACI,MAAV,CAAiBO,KAAjB,CAAuBC,QAAvB,CAAgCP,MAAhC,EAAwC,YAAM;IAC5CL,SAAS,CAACI,MAAV,CAAiBO,KAAjB,CAAuBE,aAAvB;EACD,CAFD;AAGD,CAdM;;;;AAgBA,IAAMC,gBAAgB,GAAG,SAAnBA,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GAAG,MAAH,GAAY,QALtB;MAMLM,MAAM,EAAE;IANH;EAFT,iBAWE,gCAAC,kBAAD;IACE,CAAC,EAAE1B,CADL;IAEE,OAAO,EAAEA,CAAC,CAACM,GAFb;IAGE,QAAQ,EAAC,GAHX;IAIE,KAAK,EAAEC,IAJT;IAKE,UAAU,EAAEY,IAAI,CAACQ,OAAL,CAAaC,UAL3B;IAME,QAAQ,EAAE,kBAAA3B,KAAK;MAAA,OAAIH,aAAa,CAACC,SAAD,EAAYC,CAAZ,EAAeC,KAAf,CAAjB;IAAA,CANjB;IAOE,cAAc,EAAE,wBAAAA,KAAK;MAAA,OAAIY,gBAAgB,CAACd,SAAD,EAAYE,KAAZ,CAApB;IAAA;EAPvB,GASGF,SAAS,CAAC8B,QATb,CAXF,CADF;AAyBD,CA7BD;;AA+BAZ,QAAQ,CAACa,SAAT,GAAqB;EACnBZ,UAAU,EAAEa,qBAAA,CAAUC,MADH;EAEnBzB,IAAI,EAAEwB,qBAAA,CAAUC,MAFG;EAGnBhC,CAAC,EAAE+B,qBAAA,CAAUC,MAHM;EAInBjC,SAAS,EAAEgC,qBAAA,CAAUC,MAJF;EAKnBb,IAAI,EAAEY,qBAAA,CAAUC;AALG,CAArB;eAQef,Q"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports["default"] = void 0;
|
|
7
9
|
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
8
12
|
var _react = _interopRequireDefault(require("react"));
|
|
9
13
|
|
|
10
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
15
|
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
-
|
|
14
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
15
|
-
|
|
16
16
|
var ExplicitConstructedResponse = function ExplicitConstructedResponse(props) {
|
|
17
17
|
var attributes = props.attributes,
|
|
18
18
|
value = props.value,
|
|
19
19
|
error = props.error;
|
|
20
|
-
return /*#__PURE__*/_react["default"].createElement("span",
|
|
20
|
+
return /*#__PURE__*/_react["default"].createElement("span", (0, _extends2["default"])({}, attributes, {
|
|
21
21
|
style: {
|
|
22
22
|
display: 'inline-flex',
|
|
23
23
|
minHeight: '50px',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["ExplicitConstructedResponse","props","attributes","value","error","display","minHeight","minWidth","position","margin","cursor","height","background","border","boxSizing","borderRadius","overflow","padding","__html","propTypes","PropTypes","object","string"],"sources":["../../../../src/plugins/respArea/explicit-constructed-response/index.jsx"],"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 minHeight: '50px',\n minWidth: '178px',\n position: 'relative',\n margin: '0 5px',\n cursor: 'pointer'\n }}\n >\n <div\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n height: '36px',\n background: '#FFF',\n border: `1px solid ${error ? 'red' : '#C0C3CF'}`,\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n padding: '8px'\n }}\n dangerouslySetInnerHTML={{\n __html: value || '<div> </div>'\n }}\n />\n </span>\n );\n};\n\nExplicitConstructedResponse.propTypes = {\n attributes: PropTypes.object,\n value: PropTypes.string\n};\n\nexport default ExplicitConstructedResponse;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["ExplicitConstructedResponse","props","attributes","value","error","display","minHeight","minWidth","position","margin","cursor","height","background","border","boxSizing","borderRadius","overflow","padding","__html","propTypes","PropTypes","object","string"],"sources":["../../../../src/plugins/respArea/explicit-constructed-response/index.jsx"],"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 minHeight: '50px',\n minWidth: '178px',\n position: 'relative',\n margin: '0 5px',\n cursor: 'pointer'\n }}\n >\n <div\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n minHeight: '36px',\n height: '36px',\n background: '#FFF',\n border: `1px solid ${error ? 'red' : '#C0C3CF'}`,\n boxSizing: 'border-box',\n borderRadius: '3px',\n overflow: 'hidden',\n padding: '8px'\n }}\n dangerouslySetInnerHTML={{\n __html: value || '<div> </div>'\n }}\n />\n </span>\n );\n};\n\nExplicitConstructedResponse.propTypes = {\n attributes: PropTypes.object,\n value: PropTypes.string\n};\n\nexport default ExplicitConstructedResponse;\n"],"mappings":";;;;;;;;;;;AAAA;;AACA;;AAEA,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA8B,CAAAC,KAAK,EAAI;EAC3C,IAAQC,UAAR,GAAqCD,KAArC,CAAQC,UAAR;EAAA,IAAoBC,KAApB,GAAqCF,KAArC,CAAoBE,KAApB;EAAA,IAA2BC,KAA3B,GAAqCH,KAArC,CAA2BG,KAA3B;EAEA,oBACE,sEACMF,UADN;IAEE,KAAK,EAAE;MACLG,OAAO,EAAE,aADJ;MAELC,SAAS,EAAE,MAFN;MAGLC,QAAQ,EAAE,OAHL;MAILC,QAAQ,EAAE,UAJL;MAKLC,MAAM,EAAE,OALH;MAMLC,MAAM,EAAE;IANH;EAFT,iBAWE;IACE,KAAK,EAAE;MACLL,OAAO,EAAE,aADJ;MAELE,QAAQ,EAAE,OAFL;MAGLD,SAAS,EAAE,MAHN;MAILK,MAAM,EAAE,MAJH;MAKLC,UAAU,EAAE,MALP;MAMLC,MAAM,sBAAeT,KAAK,GAAG,KAAH,GAAW,SAA/B,CAND;MAOLU,SAAS,EAAE,YAPN;MAQLC,YAAY,EAAE,KART;MASLC,QAAQ,EAAE,QATL;MAULC,OAAO,EAAE;IAVJ,CADT;IAaE,uBAAuB,EAAE;MACvBC,MAAM,EAAEf,KAAK,IAAI;IADM;EAb3B,EAXF,CADF;AA+BD,CAlCD;;AAoCAH,2BAA2B,CAACmB,SAA5B,GAAwC;EACtCjB,UAAU,EAAEkB,qBAAA,CAAUC,MADgB;EAEtClB,KAAK,EAAEiB,qBAAA,CAAUE;AAFqB,CAAxC;eAKetB,2B"}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.ToolbarIcon = exports.GripIcon = exports.Chevron = void 0;
|
|
7
9
|
|
|
10
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
+
|
|
8
12
|
var _react = _interopRequireDefault(require("react"));
|
|
9
13
|
|
|
10
14
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
@@ -15,13 +19,9 @@ var _MoreVert = _interopRequireDefault(require("@material-ui/icons/MoreVert"));
|
|
|
15
19
|
|
|
16
20
|
var _styles = require("@material-ui/core/styles");
|
|
17
21
|
|
|
18
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
|
-
|
|
20
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; }
|
|
21
23
|
|
|
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) {
|
|
23
|
-
|
|
24
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
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
25
|
|
|
26
26
|
var getRotate = function getRotate(direction) {
|
|
27
27
|
switch (direction) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["getRotate","direction","Chevron","props","style","rotate","transform","propTypes","PropTypes","string","object","GripIcon","margin","ToolbarIcon","withStyles","icon","fontFamily","fontSize","fontWeight","lineHeight","position","top","width","height","whiteSpace","classes"],"sources":["../../../../src/plugins/respArea/icons/index.jsx"],"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 case 'up':\n return -90;\n case 'left':\n return 180;\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({\n icon: {\n fontFamily: 'Cerebri Sans !important',\n fontSize: '14px',\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"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":["getRotate","direction","Chevron","props","style","rotate","transform","propTypes","PropTypes","string","object","GripIcon","margin","ToolbarIcon","withStyles","icon","fontFamily","fontSize","fontWeight","lineHeight","position","top","width","height","whiteSpace","classes"],"sources":["../../../../src/plugins/respArea/icons/index.jsx"],"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 case 'up':\n return -90;\n case 'left':\n return 180;\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({\n icon: {\n fontFamily: 'Cerebri Sans !important',\n fontSize: '14px',\n fontWeight: 'bold',\n lineHeight: '14px',\n position: 'relative',\n top: '7px',\n width: '110px',\n height: '28px',\n whiteSpace: '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C,UAAU,EAAE,MAJR;IAKJC,QAAQ,EAAE,UALN;IAMJC,GAAG,EAAE,KAND;IAOJC,KAAK,EAAE,OAPH;IAQJC,MAAM,EAAE,MARJ;IASJC,UAAU,EAAE;EATR;AAD8B,CAAX,EAYxB;EAAA,IAAGC,OAAH,SAAGA,OAAH;EAAA,oBAAiB;IAAK,SAAS,EAAEA,OAAO,CAACV;EAAxB,qBAAjB;AAAA,CAZwB,CAApB"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
@@ -22,8 +24,6 @@ var _utils = require("./utils");
|
|
|
22
24
|
|
|
23
25
|
var _icons = require("./icons");
|
|
24
26
|
|
|
25
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
26
|
-
|
|
27
27
|
var log = (0, _debug["default"])('@pie-lib:editable-html:plugins:respArea');
|
|
28
28
|
var lastIndexMap = {};
|
|
29
29
|
var elTypesMap = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["log","debug","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","getDefaultElement","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","isUndefined","forEachDescendant","parseInt","get","oldRespAreaList","disabled","arrayToFilter","arrayToUseForFilter","elementsWithChangedStatus","find","onHandleAreaChange","onDrop","event","closestEl","target","closest","inline","findDescendant","dataset","serialization","deserialize","el","id","inTable","serialize"],"sources":["../../../src/plugins/respArea/index.jsx"],"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 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 (\n <DragInTheBlank attributes={attributes} data={data} n={n} nodeProps={props} opts={opts} />\n );\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 =\n oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;\n const arrayToUseForFilter =\n 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 (\n <span\n data-type=\"explicit_constructed_response\"\n data-index={data.index}\n data-value={data.value}\n />\n );\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"],"mappings":";;;;;;;;AAAA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AE,CAACH,OAAH,CAAWlD,KADd;YAEJsD,EAAE,EAAED,EAAE,CAACH,OAAH,CAAWI,EAFX;YAGJ5E,KAAK,EAAE2E,EAAE,CAACH,OAAH,CAAWxE,KAHd;YAIJ6E,OAAO,EAAEF,EAAE,CAACH,OAAH,CAAWK;UAJhB;QAJD,CAAP;IAtBJ;EAkCD,CAtC0B;EAuC3BC,SAvC2B,qBAuCjB3C,MAvCiB,EAuCT;IAChB,IAAIA,MAAM,CAACA,MAAP,KAAkB,QAAtB,EAAgC;MAC9B;IACD;;IAED,QAAQA,MAAM,CAACzC,IAAf;MACE,KAAK,iBAAL;QAAwB;UACtB,IAAMwD,IAAI,GAAGf,MAAM,CAACe,IAAP,CAAYC,MAAZ,EAAb;UAEA,oBAAO;YAAM,aAAU,iBAAhB;YAAkC,cAAYD,IAAI,CAAC5B,KAAnD;YAA0D,cAAY4B,IAAI,CAAClD;UAA3E,EAAP;QACD;;MACD,KAAK,+BAAL;QAAsC;UACpC,IAAMkD,MAAI,GAAGf,MAAM,CAACe,IAAP,CAAYC,MAAZ,EAAb;;UAEA,oBACE;YACE,aAAU,+BADZ;YAEE,cAAYD,MAAI,CAAC5B,KAFnB;YAGE,cAAY4B,MAAI,CAAClD;UAHnB,EADF;QAOD;;MACD,KAAK,mBAAL;QAA0B;UACxB,IAAMkD,MAAI,GAAGf,MAAM,CAACe,IAAP,CAAYC,MAAZ,EAAb;;UAEA,oBACE;YACE,aAAU,mBADZ;YAEE,cAAYD,MAAI,CAAC5B,KAFnB;YAGE,WAAS4B,MAAI,CAAC0B,EAHhB;YAIE,cAAY1B,MAAI,CAAClD,KAJnB;YAKE,iBAAekD,MAAI,CAAC2B;UALtB,EADF;QASD;IA7BH;EA+BD;AA3E0B,CAAtB"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["log","debug","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","getDefaultElement","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","isUndefined","forEachDescendant","parseInt","get","oldRespAreaList","disabled","arrayToFilter","arrayToUseForFilter","elementsWithChangedStatus","find","onHandleAreaChange","onDrop","event","closestEl","target","closest","inline","findDescendant","dataset","serialization","deserialize","el","id","inTable","serialize"],"sources":["../../../src/plugins/respArea/index.jsx"],"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 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 (\n <DragInTheBlank attributes={attributes} data={data} n={n} nodeProps={props} opts={opts} />\n );\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 =\n oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;\n const arrayToUseForFilter =\n 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 (\n <span\n data-type=\"explicit_constructed_response\"\n data-index={data.index}\n data-value={data.value}\n />\n );\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"],"mappings":";;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA,IAAMA,GAAG,GAAG,IAAAC,iBAAA,EAAM,yCAAN,CAAZ;AAEA,IAAMC,YAAY,GAAG,EAArB;AACA,IAAMC,UAAU,GAAG;EACjB,mBAAmB,iBADF;EAEjB,iCAAiC,+BAFhB;EAGjB,qBAAqB;AAHJ,CAAnB;AAKA,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcH,UAAd,CAArB;;AAEe,SAASI,kBAAT,CAA4BC,IAA5B,EAAkC;EAC/C,IAAMC,eAAe,GAAG,SAAlBA,eAAkB,CAAAC,CAAC;IAAA,OAAIA,CAAC,CAACC,IAAF,KAAWH,IAAI,CAACG,IAAhB,IAAwBD,CAAC,CAACC,IAAF,KAAWR,UAAU,CAACK,IAAI,CAACG,IAAN,CAAjD;EAAA,CAAzB;;EAEA,IAAMC,OAAO,GAAG;IACdC,IAAI,eAAE,gCAAC,kBAAD,OADQ;IAEdC,YAAY,EAAE;MACZC,MAAM,EAAE;IADI,CAFA;IAKdC,OAAO,EAAE,iBAACC,KAAD,EAAQC,QAAR,EAAqB;MAC5BlB,GAAG,CAAC,mBAAD,CAAH;MACA,IAAMmB,MAAM,GAAGF,KAAK,CAACE,MAAN,EAAf;MACA,IAAMC,mBAAmB,GAAGD,MAAM,CAACF,KAAP,CAAaI,QAAb,CAAsBC,iBAAtB,CAAwCb,eAAxC,CAA5B;;MAEA,IA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