@pie-element/explicit-constructed-response 6.12.2-next.20 → 6.12.2-next.27
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.
|
@@ -29,6 +29,8 @@ var _styles = require("@material-ui/core/styles");
|
|
|
29
29
|
|
|
30
30
|
var _OutlinedInput = _interopRequireDefault(require("@material-ui/core/OutlinedInput"));
|
|
31
31
|
|
|
32
|
+
var _slateReact = require("slate-react");
|
|
33
|
+
|
|
32
34
|
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; }
|
|
33
35
|
|
|
34
36
|
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; }
|
|
@@ -37,10 +39,6 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
37
39
|
|
|
38
40
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
39
41
|
|
|
40
|
-
var findSlateNode = function findSlateNode(key) {
|
|
41
|
-
return window.document.querySelector('[data-key="' + key + '"]');
|
|
42
|
-
};
|
|
43
|
-
|
|
44
42
|
var ECRToolbar = /*#__PURE__*/function (_React$Component) {
|
|
45
43
|
(0, _inherits2["default"])(ECRToolbar, _React$Component);
|
|
46
44
|
|
|
@@ -59,7 +57,7 @@ var ECRToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
59
57
|
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "state", {
|
|
60
58
|
markup: ''
|
|
61
59
|
});
|
|
62
|
-
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDone", function () {
|
|
60
|
+
(0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "onDone", function (e) {
|
|
63
61
|
var newValue = _this.state.markup;
|
|
64
62
|
var _this$props = _this.props,
|
|
65
63
|
node = _this$props.node,
|
|
@@ -72,6 +70,15 @@ var ECRToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
72
70
|
value: newValue
|
|
73
71
|
});
|
|
74
72
|
|
|
73
|
+
var domNode = _slateReact.ReactEditor.toDOMNode(editor, node);
|
|
74
|
+
|
|
75
|
+
var slateWrapperForNode = domNode === null || domNode === void 0 ? void 0 : domNode.closest('[data-slate-wrapper]');
|
|
76
|
+
|
|
77
|
+
if (e !== null && e !== void 0 && e.relatedTarget && e.relatedTarget.closest('[data-slate-wrapper]') === slateWrapperForNode) {
|
|
78
|
+
// no need to call the blur function if the click is on the slate editor
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
75
82
|
editor && editor.apply({
|
|
76
83
|
type: 'set_node',
|
|
77
84
|
path: nodePath,
|
|
@@ -97,24 +104,26 @@ var ECRToolbar = /*#__PURE__*/function (_React$Component) {
|
|
|
97
104
|
key: "componentDidMount",
|
|
98
105
|
value: function componentDidMount() {
|
|
99
106
|
var _this$props2 = this.props,
|
|
107
|
+
editor = _this$props2.editor,
|
|
100
108
|
correctChoice = _this$props2.correctChoice,
|
|
101
109
|
node = _this$props2.node;
|
|
102
110
|
var choice = correctChoice || {};
|
|
103
|
-
|
|
111
|
+
|
|
112
|
+
var domNode = _slateReact.ReactEditor.toDOMNode(editor, node);
|
|
104
113
|
|
|
105
114
|
if (domNode) {
|
|
106
|
-
//eslint-disable-next-line
|
|
115
|
+
// eslint-disable-next-line
|
|
107
116
|
var domNodeRect = domNode.getBoundingClientRect();
|
|
108
|
-
var
|
|
109
|
-
var editorRect =
|
|
117
|
+
var editorDOM = domNode.closest('[data-slate-editor]');
|
|
118
|
+
var editorRect = editorDOM.getBoundingClientRect();
|
|
110
119
|
var top = domNodeRect.top - editorRect.top;
|
|
111
120
|
var left = domNodeRect.left - editorRect.left;
|
|
112
121
|
this.setState({
|
|
113
122
|
markup: choice.label,
|
|
114
123
|
toolbarStyle: {
|
|
115
124
|
position: 'absolute',
|
|
116
|
-
top: "".concat(top + domNodeRect.height
|
|
117
|
-
left: "".concat(left +
|
|
125
|
+
top: "".concat(top + domNodeRect.height - 1, "px"),
|
|
126
|
+
left: "".concat(left + 17, "px"),
|
|
118
127
|
width: domNodeRect.width
|
|
119
128
|
}
|
|
120
129
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ecr-toolbar.jsx"],"names":["
|
|
1
|
+
{"version":3,"sources":["../src/ecr-toolbar.jsx"],"names":["ECRToolbar","markup","e","newValue","state","props","node","nodePath","editor","onToolbarDone","onChangeResponse","update","data","value","domNode","ReactEditor","toDOMNode","slateWrapperForNode","closest","relatedTarget","apply","type","path","properties","newProperties","setState","target","correctChoice","choice","domNodeRect","getBoundingClientRect","editorDOM","editorRect","top","left","label","toolbarStyle","position","height","width","classes","maxLengthPerChoiceEnabled","inputProps","maxLength","backgroundColor","input","onChange","onDone","React","Component","PropTypes","object","array","func","isRequired","bool","StyledECRToolbar","theme","respArea","palette","common","white","padding","errorInput","border","error","main"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;IAEaA,U;;;;;;;;;;;;;;;8FAaH;AACNC,MAAAA,MAAM,EAAE;AADF,K;+FA8BC,UAACC,CAAD,EAAO;AACd,UAAgBC,QAAhB,GAA6B,MAAKC,KAAl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AA,KAAK,EAAE;AACLD,MAAAA,eAAe,EAAEa,KAAK,CAACE,OAAN,CAAcC,MAAd,CAAqBC,KADjC;AAELC,MAAAA,OAAO,EAAE;AAFJ,KAJuC;AAQ9CC,IAAAA,UAAU,EAAE;AACVC,MAAAA,MAAM,sBAAeP,KAAK,CAACE,OAAN,CAAcM,KAAd,CAAoBC,IAAnC;AADI;AARkC,GAAZ;AAAA,CAAX,EAWrBlE,UAXqB,CAAzB;eAaewD,gB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport OutlinedInput from '@material-ui/core/OutlinedInput';\nimport { ReactEditor } from 'slate-react';\n\nexport class ECRToolbar extends React.Component {\n static propTypes = {\n correctChoice: PropTypes.object,\n classes: PropTypes.object,\n node: PropTypes.object,\n nodePath: PropTypes.array,\n onDone: PropTypes.func,\n onChangeResponse: PropTypes.func.isRequired,\n onToolbarDone: PropTypes.func.isRequired,\n editor: PropTypes.object,\n maxLengthPerChoiceEnabled: PropTypes.bool,\n };\n\n state = {\n markup: '',\n };\n\n componentDidMount() {\n const { editor, correctChoice, node } = this.props;\n const choice = correctChoice || {};\n\n const domNode = ReactEditor.toDOMNode(editor, node);\n\n if (domNode) {\n // eslint-disable-next-line\n const domNodeRect = domNode.getBoundingClientRect();\n const editorDOM = domNode.closest('[data-slate-editor]');\n const editorRect = editorDOM.getBoundingClientRect();\n const top = domNodeRect.top - editorRect.top;\n const left = domNodeRect.left - editorRect.left;\n\n this.setState({\n markup: choice.label,\n toolbarStyle: {\n position: 'absolute',\n top: `${top + domNodeRect.height - 1}px`,\n left: `${left + 17}px`,\n width: domNodeRect.width,\n },\n });\n }\n }\n\n onDone = (e) => {\n const { markup: newValue } = this.state;\n const { node, nodePath, editor, onToolbarDone, onChangeResponse } = this.props;\n const update = { ...node.data, value: newValue };\n\n const domNode = ReactEditor.toDOMNode(editor, node);\n const slateWrapperForNode = domNode?.closest('[data-slate-wrapper]')\n\n if (e?.relatedTarget && e.relatedTarget.closest('[data-slate-wrapper]') === slateWrapperForNode) {\n // no need to call the blur function if the click is on the slate editor\n return;\n }\n\n editor && editor.apply({\n type: 'set_node',\n path: nodePath,\n properties: {\n data: node.data\n },\n newProperties: { data: update }\n });\n\n onToolbarDone(true);\n onChangeResponse(newValue);\n };\n\n onChange = (e) => this.setState({ markup: e.target.value });\n\n render() {\n const { classes, node, maxLengthPerChoiceEnabled } = this.props;\n const { markup, toolbarStyle } = this.state;\n const inputProps = maxLengthPerChoiceEnabled ? {} : { maxLength: 25 };\n\n return (\n <div\n style={{\n ...toolbarStyle,\n backgroundColor: '#E0E1E6',\n }}\n >\n <OutlinedInput\n style={{ width: '100%' }}\n autoFocus\n labelWidth={0}\n classes={{\n input: classes.input,\n }}\n onChange={this.onChange}\n onBlur={this.onDone}\n value={markup || node?.data?.value || ''}\n inputProps={inputProps}\n />\n </div>\n );\n }\n}\n\nconst StyledECRToolbar = withStyles((theme) => ({\n respArea: {\n backgroundColor: theme.palette.common.white,\n },\n input: {\n backgroundColor: theme.palette.common.white,\n padding: '10px 20px 10px 10px',\n },\n errorInput: {\n border: `2px solid ${theme.palette.error.main}`,\n },\n}))(ECRToolbar);\n\nexport default StyledECRToolbar;\n"],"file":"ecr-toolbar.js"}
|
package/configure/package.json
CHANGED
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
6
|
"repository": "pie-framework/pie-elements",
|
|
7
|
-
"version": "6.12.2-next.
|
|
7
|
+
"version": "6.12.2-next.27+b36b61663",
|
|
8
8
|
"description": "",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postpublish": "../../scripts/postpublish"
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
},
|
|
22
22
|
"author": "",
|
|
23
23
|
"license": "ISC",
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "b36b616638734105121dcc6610069bfab163a5e2",
|
|
25
25
|
"main": "lib/index.js",
|
|
26
26
|
"module": "src/index.js",
|
|
27
27
|
"exports": {
|