@pie-lib/render-ui 4.12.1-next.86 → 4.12.1-next.93
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/preview-prompt.js +31 -4
- package/lib/preview-prompt.js.map +1 -1
- package/package.json +3 -3
- package/src/preview-prompt.jsx +20 -1
package/lib/preview-prompt.js
CHANGED
|
@@ -27,10 +27,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
27
27
|
|
|
28
28
|
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
29
29
|
|
|
30
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
31
|
-
|
|
32
30
|
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
33
31
|
|
|
32
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
33
|
+
|
|
34
34
|
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 } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
35
35
|
|
|
36
36
|
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
@@ -47,9 +47,36 @@ function (_Component) {
|
|
|
47
47
|
_inherits(PreviewPrompt, _Component);
|
|
48
48
|
|
|
49
49
|
function PreviewPrompt() {
|
|
50
|
+
var _getPrototypeOf2;
|
|
51
|
+
|
|
52
|
+
var _this;
|
|
53
|
+
|
|
50
54
|
_classCallCheck(this, PreviewPrompt);
|
|
51
55
|
|
|
52
|
-
|
|
56
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
57
|
+
args[_key] = arguments[_key];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_this = _possibleConstructorReturn(this, (_getPrototypeOf2 = _getPrototypeOf(PreviewPrompt)).call.apply(_getPrototypeOf2, [this].concat(args)));
|
|
61
|
+
|
|
62
|
+
_defineProperty(_assertThisInitialized(_this), "parsedText", function (text) {
|
|
63
|
+
// fix imported audio content for Safari PD-1419
|
|
64
|
+
var div = document.createElement('div');
|
|
65
|
+
div.innerHTML = text;
|
|
66
|
+
var audio = div.querySelector('audio');
|
|
67
|
+
|
|
68
|
+
if (audio) {
|
|
69
|
+
var source = document.createElement('source');
|
|
70
|
+
source.setAttribute('type', 'audio/mp3');
|
|
71
|
+
source.setAttribute('src', audio.getAttribute('src'));
|
|
72
|
+
audio.removeAttribute('src');
|
|
73
|
+
audio.appendChild(source);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return div.innerHTML;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
return _this;
|
|
53
80
|
}
|
|
54
81
|
|
|
55
82
|
_createClass(PreviewPrompt, [{
|
|
@@ -68,7 +95,7 @@ function (_Component) {
|
|
|
68
95
|
onClick: onClick,
|
|
69
96
|
className: customClasses,
|
|
70
97
|
dangerouslySetInnerHTML: {
|
|
71
|
-
__html: (prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX)
|
|
98
|
+
__html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX)
|
|
72
99
|
}
|
|
73
100
|
});
|
|
74
101
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/preview-prompt.jsx"],"names":["NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","PreviewPrompt","props","prompt","classes","tagName","className","onClick","defaultClassName","CustomTag","customClasses","promptTable","__html","replace","Component","PropTypes","object","string","func","styles","theme","verticalAlign","color","
|
|
1
|
+
{"version":3,"sources":["../src/preview-prompt.jsx"],"names":["NEWLINE_BLOCK_REGEX","NEWLINE_LATEX","PreviewPrompt","text","div","document","createElement","innerHTML","audio","querySelector","source","setAttribute","getAttribute","removeAttribute","appendChild","props","prompt","classes","tagName","className","onClick","defaultClassName","CustomTag","customClasses","promptTable","__html","parsedText","replace","Component","PropTypes","object","string","func","styles","theme","verticalAlign","color","rationale","paddingLeft","spacing","unit","label","display","cursor","borderCollapse","borderTop","backgroundColor","border","padding","textAlign"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;AACA,IAAMA,mBAAmB,GAAG,yBAA5B;AACA,IAAMC,aAAa,GAAG,YAAtB;;IAEaC,a;;;;;;;;;;;;;;;;;;iEAcE,UAAAC,IAAI,EAAI;AACnB;AACA,UAAMC,GAAG,GAAGC,QAAQ,CAACC,aAAT,CAAuB,KAAvB,CAAZ;AACAF,MAAAA,GAAG,CAACG,SAAJ,GAAgBJ,IAAhB;AAEA,UAAMK,KAAK,GAAGJ,GAAG,CAACK,aAAJ,CAAkB,OAAlB,CAAd;;AACA,UAAID,KAAJ,EAAW;AACT,YAAME,MAAM,GAAGL,QAAQ,CAACC,aAAT,CAAuB,QAAvB,CAAf;AAEAI,QAAAA,MAAM,CAACC,YAAP,CAAoB,MAApB,EAA4B,WAA5B;AACAD,QAAAA,MAAM,CAACC,YAAP,CAAoB,KAApB,EAA2BH,KAAK,CAACI,YAAN,CAAmB,KAAnB,CAA3B;AAEAJ,QAAAA,KAAK,CAACK,eAAN,CAAsB,KAAtB;AACAL,QAAAA,KAAK,CAACM,WAAN,CAAkBJ,MAAlB;AACD;;AAED,aAAON,GAAG,CAACG,SAAX;AACD,K;;;;;;;6BAEQ;AAAA,wBACoE,KAAKQ,KADzE;AAAA,UACCC,MADD,eACCA,MADD;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GAAqB;AADzB,KALY;AAQvBC,IAAAA,KAAK,EAAE;AACLL,MAAAA,KAAK,YAAKA,KAAK,CAACjC,IAAN,EAAL,gBADA;AACgC;AACrCuC,MAAAA,OAAO,EAAE,cAFJ;AAGLP,MAAAA,aAAa,EAAE,QAHV;AAILQ,MAAAA,MAAM,EAAE;AAJH,KARgB;AAcvBnB,IAAAA,WAAW,EAAE;AACX,iCAA2B;AACzBoB,QAAAA,cAAc,EAAE;AADS,OADhB;AAIX,oCAA8B;AAC5BC,QAAAA,SAAS,EAAE,mBADiB;AAE5B,2BAAmB;AACjBC,UAAAA,eAAe,EAAE;AADA;AAFS,OAJnB;AAUX,gEAA0D;AACxDC,QAAAA,MAAM,EAAE,mBADgD;AAExDC,QAAAA,OAAO,EAAE,UAF+C;AAGxDC,QAAAA,SAAS,EAAE;AAH6C;AAV/C;AAdU,GAAL;AAAA,CAApB;;eA+Be,wBAAWhB,MAAX,EAAmB/B,aAAnB,C","sourcesContent":["import React, { Component } from 'react';\nimport { withStyles } from '@material-ui/core/styles';\nimport PropTypes from 'prop-types';\nimport * as color from './color';\n\n//Used these below to replace \\\\embed{newLine} with \\\\newline from prompt which will get parsed in MathJax\nconst NEWLINE_BLOCK_REGEX = /\\\\embed\\{newLine\\}\\[\\]/g;\nconst NEWLINE_LATEX = '\\\\newline ';\n\nexport class PreviewPrompt extends Component {\n static propTypes = {\n classes: PropTypes.object,\n prompt: PropTypes.string,\n tagName: PropTypes.string,\n className: PropTypes.string,\n onClick: PropTypes.func,\n defaultClassName: PropTypes.string\n };\n\n static defaultProps = {\n onClick: () => {}\n };\n\n parsedText = text => {\n // fix imported audio content for Safari PD-1419\n const div = document.createElement('div');\n div.innerHTML = text;\n\n const audio = div.querySelector('audio');\n if (audio) {\n const source = document.createElement('source');\n\n source.setAttribute('type', 'audio/mp3');\n source.setAttribute('src', audio.getAttribute('src'));\n\n audio.removeAttribute('src');\n audio.appendChild(source);\n }\n\n return div.innerHTML;\n };\n\n render() {\n const { prompt, classes, tagName, className, onClick, defaultClassName } = this.props;\n const CustomTag = tagName || 'div';\n const customClasses = `${classes.promptTable} ${classes[className] || ''} ${defaultClassName ||\n ''}`;\n\n return (\n <CustomTag\n onClick={onClick}\n className={customClasses}\n dangerouslySetInnerHTML={{\n __html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX)\n }}\n />\n );\n }\n}\n\nconst styles = theme => ({\n prompt: {\n verticalAlign: 'middle',\n color: color.text()\n },\n rationale: {\n paddingLeft: theme.spacing.unit * 16\n },\n label: {\n color: `${color.text()} !important`, //'var(--choice-input-color, black)',\n display: 'inline-block',\n verticalAlign: 'middle',\n cursor: 'pointer'\n },\n promptTable: {\n '&:not(.MathJax) > table': {\n borderCollapse: 'collapse'\n },\n '&:not(.MathJax) > table tr': {\n borderTop: '1px solid #dfe2e5',\n '&:nth-child(2n)': {\n backgroundColor: '#f6f8fa'\n }\n },\n '&:not(.MathJax) > table td, &:not(.MathJax) > table th': {\n border: '1px solid #dfe2e5',\n padding: '.6em 1em',\n textAlign: 'center'\n }\n }\n});\nexport default withStyles(styles)(PreviewPrompt);\n"],"file":"preview-prompt.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-lib/render-ui",
|
|
3
|
-
"version": "4.12.1-next.
|
|
3
|
+
"version": "4.12.1-next.93+b0f7d4b9",
|
|
4
4
|
"description": "Some shared ui elements when rendering - but not worthy of their own package yet.",
|
|
5
5
|
"module": "src/index.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"@material-ui/core": "^3.8.3",
|
|
13
13
|
"@material-ui/icons": "^3.0.2",
|
|
14
14
|
"@pie-lib/icons": "^2.4.25",
|
|
15
|
-
"@pie-lib/math-rendering": "^2.3.
|
|
15
|
+
"@pie-lib/math-rendering": "^2.3.9",
|
|
16
16
|
"classnames": "^2.2.6",
|
|
17
17
|
"debug": "^4.1.1",
|
|
18
18
|
"prop-types": "^15.7.2",
|
|
@@ -26,5 +26,5 @@
|
|
|
26
26
|
"react": "^16.8.1",
|
|
27
27
|
"react-dom": "^16.8.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "b0f7d4b985f02c4d3f830e8183c34bbe0ca8f199"
|
|
30
30
|
}
|
package/src/preview-prompt.jsx
CHANGED
|
@@ -21,6 +21,25 @@ export class PreviewPrompt extends Component {
|
|
|
21
21
|
onClick: () => {}
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
+
parsedText = text => {
|
|
25
|
+
// fix imported audio content for Safari PD-1419
|
|
26
|
+
const div = document.createElement('div');
|
|
27
|
+
div.innerHTML = text;
|
|
28
|
+
|
|
29
|
+
const audio = div.querySelector('audio');
|
|
30
|
+
if (audio) {
|
|
31
|
+
const source = document.createElement('source');
|
|
32
|
+
|
|
33
|
+
source.setAttribute('type', 'audio/mp3');
|
|
34
|
+
source.setAttribute('src', audio.getAttribute('src'));
|
|
35
|
+
|
|
36
|
+
audio.removeAttribute('src');
|
|
37
|
+
audio.appendChild(source);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return div.innerHTML;
|
|
41
|
+
};
|
|
42
|
+
|
|
24
43
|
render() {
|
|
25
44
|
const { prompt, classes, tagName, className, onClick, defaultClassName } = this.props;
|
|
26
45
|
const CustomTag = tagName || 'div';
|
|
@@ -32,7 +51,7 @@ export class PreviewPrompt extends Component {
|
|
|
32
51
|
onClick={onClick}
|
|
33
52
|
className={customClasses}
|
|
34
53
|
dangerouslySetInnerHTML={{
|
|
35
|
-
__html: (prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX)
|
|
54
|
+
__html: this.parsedText(prompt || '').replace(NEWLINE_BLOCK_REGEX, NEWLINE_LATEX)
|
|
36
55
|
}}
|
|
37
56
|
/>
|
|
38
57
|
);
|