@pie-lib/editable-html 7.18.0 → 7.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/lib/editor.js +27 -20
- package/lib/editor.js.map +1 -1
- package/lib/index.js +27 -21
- package/lib/index.js.map +1 -1
- package/lib/plugins/image/component.js +20 -18
- package/lib/plugins/image/component.js.map +1 -1
- package/lib/plugins/image/image-toolbar.js +21 -19
- package/lib/plugins/image/image-toolbar.js.map +1 -1
- package/lib/plugins/image/index.js +7 -7
- package/lib/plugins/image/index.js.map +1 -1
- package/lib/plugins/image/insert-image-handler.js +2 -4
- package/lib/plugins/image/insert-image-handler.js.map +1 -1
- package/lib/plugins/index.js +7 -7
- package/lib/plugins/index.js.map +1 -1
- package/lib/plugins/list/index.js +7 -7
- package/lib/plugins/list/index.js.map +1 -1
- package/lib/plugins/math/index.js +13 -12
- package/lib/plugins/math/index.js.map +1 -1
- package/lib/plugins/media/index.js +16 -13
- package/lib/plugins/media/index.js.map +1 -1
- package/lib/plugins/media/media-dialog.js +27 -23
- package/lib/plugins/media/media-dialog.js.map +1 -1
- package/lib/plugins/media/media-toolbar.js +19 -15
- package/lib/plugins/media/media-toolbar.js.map +1 -1
- package/lib/plugins/media/media-wrapper.js +20 -14
- package/lib/plugins/media/media-wrapper.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/choice.js +25 -19
- package/lib/plugins/respArea/drag-in-the-blank/choice.js.map +1 -1
- package/lib/plugins/respArea/drag-in-the-blank/index.js +6 -6
- package/lib/plugins/respArea/drag-in-the-blank/index.js.map +1 -1
- package/lib/plugins/respArea/explicit-constructed-response/index.js +3 -3
- package/lib/plugins/respArea/explicit-constructed-response/index.js.map +1 -1
- package/lib/plugins/respArea/icons/index.js +7 -7
- package/lib/plugins/respArea/icons/index.js.map +1 -1
- package/lib/plugins/respArea/index.js +36 -9
- package/lib/plugins/respArea/index.js.map +1 -1
- package/lib/plugins/respArea/inline-dropdown/index.js +4 -4
- package/lib/plugins/respArea/inline-dropdown/index.js.map +1 -1
- package/lib/plugins/respArea/utils.js +3 -3
- package/lib/plugins/respArea/utils.js.map +1 -1
- package/lib/plugins/table/icons/index.js +8 -8
- package/lib/plugins/table/icons/index.js.map +1 -1
- package/lib/plugins/table/index.js +19 -19
- package/lib/plugins/table/index.js.map +1 -1
- package/lib/plugins/table/table-toolbar.js +26 -24
- package/lib/plugins/table/table-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/default-toolbar.js +7 -7
- package/lib/plugins/toolbar/default-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/done-button.js +3 -3
- package/lib/plugins/toolbar/done-button.js.map +1 -1
- package/lib/plugins/toolbar/editor-and-toolbar.js +23 -19
- package/lib/plugins/toolbar/editor-and-toolbar.js.map +1 -1
- package/lib/plugins/toolbar/index.js +1 -1
- package/lib/plugins/toolbar/index.js.map +1 -1
- package/lib/plugins/toolbar/toolbar-buttons.js +22 -18
- package/lib/plugins/toolbar/toolbar-buttons.js.map +1 -1
- package/lib/plugins/toolbar/toolbar.js +25 -21
- package/lib/plugins/toolbar/toolbar.js.map +1 -1
- package/lib/plugins/utils.js +1 -1
- package/lib/serialization.js +4 -4
- package/lib/serialization.js.map +1 -1
- package/package.json +2 -2
- package/src/editor.jsx +4 -2
- package/src/plugins/respArea/explicit-constructed-response/index.jsx +1 -1
- package/src/plugins/respArea/index.jsx +28 -2
- package/src/plugins/toolbar/toolbar.jsx +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/respArea/drag-in-the-blank/choice.jsx"],"names":["useStyles","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","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","over","tileTarget","drop","monitor","draggedItem","getItem","shouldDrop","index","onChange","dropped","canDrop","instanceId","DropTile","connect","dropTarget","tileSource","canDrag","disabled","beginDrag","id","targetId","fromChoice","endDrag","dropResult","getDropResult","duplicates","removeResponse","dragSource"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,wBAAW,UAAAC,KAAK;AAAA,SAAK;AACrCC,IAAAA,OAAO,EAAE;AACPC,MAAAA,MAAM,sBAAeF,KAAK,CAACG,OAAN,CAAcC,OAAd,CAAsBC,IAArC;AADC,KAD4B;AAIrCC,IAAAA,IAAI,EAAE;AACJC,MAAAA,QAAQ,EAAE;AADN,KAJ+B;AAOrCC,IAAAA,OAAO,EAAE;AACPN,MAAAA,MAAM,EAAE;AADD,KAP4B;AAUrCO,IAAAA,SAAS,EAAE;AACTP,MAAAA,MAAM,EAAE;AADC,KAV0B;AAarCQ,IAAAA,QAAQ,EAAE;AACRR,MAAAA,MAAM,sBAAeS,gBAAMC,WAAN,EAAf;AADE;AAb2B,GAAL;AAAA,CAAhB,CAAlB;;IAkBaC,Y;;;;;AAWX,wBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,sFAAMA,KAAN;AAEA,UAAKC,WAAL,GAAmB,MAAKA,WAAL,CAAiBC,IAAjB,+BAAnB;AAHiB;AAIlB;;;;wCAEmB;AAClBC,MAAAA,QAAQ,CAACC,gBAAT,CAA0B,OAA1B,EAAmC,KAAKH,WAAxC;AACD;;;2CAEsB;AACrBE,MAAAA,QAAQ,CAACE,mBAAT,CAA6B,OAA7B,EAAsC,KAAKJ,WAA3C;AACD;;;gCAEWK,K,EAAO;AAAA,UACTC,OADS,GACG,KAAKP,KADR,CACTO,OADS;;AAGjB,UAAI,KAAKC,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H+E,GAAvB;AAAA,CAAnD,EAIbV,qBAJa,CAAjB;AAMO,IAAMoB,UAAU,GAAG;AACxBC,EAAAA,OADwB,mBAChB9D,KADgB,EACT;AACb,WAAO,CAACA,KAAK,CAAC+D,QAAP,IAAmB,CAAC,CAAC/D,KAAK,CAACiB,KAAlC;AACD,GAHuB;AAIxB+C,EAAAA,SAJwB,qBAIdhE,KAJc,EAIP;AACf,WAAO;AACLiE,MAAAA,EAAE,EAAEjE,KAAK,CAACkE,QADL;AAELjD,MAAAA,KAAK,EAAEjB,KAAK,CAACiB,KAFR;AAGLwC,MAAAA,UAAU,EAAEzD,KAAK,CAACyD,UAHb;AAILU,MAAAA,UAAU,EAAE;AAJP,KAAP;AAMD,GAXuB;AAYxBC,EAAAA,OAZwB,mBAYhBpE,KAZgB,EAYTiD,OAZS,EAYA;AACtB;AACA,QAAMoB,UAAU,GAAGpB,OAAO,CAACqB,aAAR,EAAnB;;AAEA,QAAI,CAACD,UAAD,IAAgBA,UAAU,CAACd,OAAX,IAAsB,CAACvD,KAAK,CAACuE,UAAjD,EAA8D;AAC5D,UAAMrB,WAAW,GAAGD,OAAO,CAACE,OAAR,EAApB;;AAEA,UAAID,WAAW,CAACiB,UAAhB,EAA4B;AAC1BnE,QAAAA,KAAK,CAACwE,cAAN,CAAqBtB,WAAW,CAACjC,KAAjC;AACD;AACF;AACF;AAvBuB,CAAnB;;;eA0BQ,sBAAW,0BAAX,EAAuC4C,UAAvC,EAAmD,UAACF,OAAD,EAAUV,OAAV;AAAA,SAAuB;AACvFN,IAAAA,iBAAiB,EAAEgB,OAAO,CAACc,UAAR,EADoE;AAEvF3D,IAAAA,UAAU,EAAEmC,OAAO,CAACnC,UAAR;AAF2E,GAAvB;AAAA,CAAnD,EAGX4C,QAHW,C","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"],"file":"choice.js"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/respArea/drag-in-the-blank/choice.jsx"],"names":["useStyles","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","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","over","tileTarget","drop","monitor","draggedItem","getItem","shouldDrop","index","onChange","dropped","canDrop","instanceId","DropTile","connect","dropTarget","tileSource","canDrag","disabled","beginDrag","id","targetId","fromChoice","endDrag","dropResult","getDropResult","duplicates","removeResponse","dragSource"],"mappings":";;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,wBAAW,UAAAC,KAAK;AAAA,SAAK;AACrCC,IAAAA,OAAO,EAAE;AACPC,MAAAA,MAAM,sBAAeF,KAAK,CAACG,OAAN,CAAcC,OAAd,CAAsBC,IAArC;AADC,KAD4B;AAIrCC,IAAAA,IAAI,EAAE;AACJC,MAAAA,QAAQ,EAAE;AADN,KAJ+B;AAOrCC,IAAAA,OAAO,EAAE;AACPN,MAAAA,MAAM,EAAE;AADD,KAP4B;AAUrCO,IAAAA,SAAS,EAAE;AACTP,MAAAA,MAAM,EAAE;AADC,KAV0B;AAarCQ,IAAAA,QAAQ,EAAE;AACRR,MAAAA,MAAM,sBAAeS,gBAAMC,WAAN,EAAf;AADE;AAb2B,GAAL;AAAA,CAAhB,CAAlB;;IAkBaC,Y;;;;;AAWX,wBAAYC,KAAZ,EAAmB;AAAA;;AAAA;;AACjB,8BAAMA,KAAN;AAEA,UAAKC,WAAL,GAAmB,MAAKA,WAAL,CAAiBC,IAAjB,+BAAnB;AAHiB;AAIlB;;;;WAED,6BAAoB;AAClBC,MAAAA,QAAQ,CAACC,gBAAT,CAA0B,OAA1B,EAAmC,KAAKH,WAAxC;AACD;;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ADoE;AAEvF3D,IAAAA,UAAU,EAAEmC,OAAO,CAACnC,UAAR;AAF2E,GAAvB;AAAA,CAAnD,EAGX4C,QAHW,C","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"],"file":"choice.js"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
exports.onValueChange = exports.onRemoveResponse = exports["default"] = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -15,9 +15,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
15
15
|
|
|
16
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
17
|
|
|
18
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
18
|
+
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
19
|
|
|
20
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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) { _defineProperty(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; }
|
|
21
21
|
|
|
22
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; }
|
|
23
23
|
|
|
@@ -25,7 +25,7 @@ var onValueChange = function onValueChange(nodeProps, n, value) {
|
|
|
25
25
|
var val = nodeProps.editor.value;
|
|
26
26
|
var change = val.change();
|
|
27
27
|
change.setNodeByKey(n.key, {
|
|
28
|
-
data: _objectSpread({}, value, {
|
|
28
|
+
data: _objectSpread(_objectSpread({}, value), {}, {
|
|
29
29
|
index: n.data.get('index')
|
|
30
30
|
})
|
|
31
31
|
});
|
|
@@ -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 _react["default"].createElement("span", _extends({}, attributes, {
|
|
64
|
+
return /*#__PURE__*/_react["default"].createElement("span", _extends({}, attributes, {
|
|
65
65
|
style: {
|
|
66
66
|
display: 'inline-flex',
|
|
67
67
|
minHeight: '50px',
|
|
@@ -70,7 +70,7 @@ var DragDrop = function DragDrop(props) {
|
|
|
70
70
|
margin: inTable ? '10px' : '0 10px',
|
|
71
71
|
cursor: 'pointer'
|
|
72
72
|
}
|
|
73
|
-
}), _react["default"].createElement(_choice["default"], {
|
|
73
|
+
}), /*#__PURE__*/_react["default"].createElement(_choice["default"], {
|
|
74
74
|
n: n,
|
|
75
75
|
dragKey: n.key,
|
|
76
76
|
targetId: "0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/respArea/drag-in-the-blank/index.jsx"],"names":["onValueChange","nodeProps","n","value","val","editor","change","setNodeByKey","key","data","index","get","props","onChange","onEditingDone","onRemoveResponse","dragInTheBlank","document","findDescendant","DragDrop","attributes","opts","inTable","display","minHeight","minWidth","position","margin","cursor","options","duplicates","children","propTypes","PropTypes","object"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,SAAD,EAAYC,CAAZ,EAAeC,KAAf,EAAyB;AACpD,MAAMC,GAAG,GAAGH,SAAS,CAACI,MAAV,CAAiBF,KAA7B;AACA,MAAMG,MAAM,GAAGF,GAAG,CAACE,MAAJ,EAAf;AAEAA,EAAAA,MAAM,CAACC,YAAP,CAAoBL,CAAC,CAACM,GAAtB,EAA2B;AACzBC,IAAAA,IAAI,
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/respArea/drag-in-the-blank/index.jsx"],"names":["onValueChange","nodeProps","n","value","val","editor","change","setNodeByKey","key","data","index","get","props","onChange","onEditingDone","onRemoveResponse","dragInTheBlank","document","findDescendant","DragDrop","attributes","opts","inTable","display","minHeight","minWidth","position","margin","cursor","options","duplicates","children","propTypes","PropTypes","object"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;AAEO,IAAMA,aAAa,GAAG,SAAhBA,aAAgB,CAACC,SAAD,EAAYC,CAAZ,EAAeC,KAAf,EAAyB;AACpD,MAAMC,GAAG,GAAGH,SAAS,CAACI,MAAV,CAAiBF,KAA7B;AACA,MAAMG,MAAM,GAAGF,GAAG,CAACE,MAAJ,EAAf;AAEAA,EAAAA,MAAM,CAACC,YAAP,CAAoBL,CAAC,CAACM,GAAtB,EAA2B;AACzBC,IAAAA,IAAI,kCACCN,KADD;AAEFO,MAAAA,KAAK,EAAER,CAAC,CAACO,IAAF,CAAOE,GAAP,CAAW,OAAX;AAFL;AADqB,GAA3B;AAOAV,EAAAA,SAAS,CAACI,MAAV,CAAiBO,KAAjB,CAAuBC,QAAvB,CAAgCP,MAAhC,EAAwC,YAAM;AAC5CL,IAAAA,SAAS,CAACI,MAAV,CAAiBO,KAAjB,CAAuBE,aAAvB;AACD,GAFD;AAGD,CAdM;;;;AAgBA,IAAMC,gBAAgB,GAAG,SAAnBA,gBAAmB,CAACd,SAAD,EAAYE,KAAZ,EAA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UAJL;AAKLC,MAAAA,MAAM,EAAEL,OAAO,GAAG,MAAH,GAAY,QALtB;AAMLM,MAAAA,MAAM,EAAE;AANH;AAFT,mBAWE,gCAAC,kBAAD;AACE,IAAA,CAAC,EAAE1B,CADL;AAEE,IAAA,OAAO,EAAEA,CAAC,CAACM,GAFb;AAGE,IAAA,QAAQ,EAAC,GAHX;AAIE,IAAA,KAAK,EAAEC,IAJT;AAKE,IAAA,UAAU,EAAEY,IAAI,CAACQ,OAAL,CAAaC,UAL3B;AAME,IAAA,QAAQ,EAAE,kBAAA3B,KAAK;AAAA,aAAIH,aAAa,CAACC,SAAD,EAAYC,CAAZ,EAAeC,KAAf,CAAjB;AAAA,KANjB;AAOE,IAAA,cAAc,EAAE,wBAAAA,KAAK;AAAA,aAAIY,gBAAgB,CAACd,SAAD,EAAYE,KAAZ,CAApB;AAAA;AAPvB,KASGF,SAAS,CAAC8B,QATb,CAXF,CADF;AAyBD,CA7BD;;AA+BAZ,QAAQ,CAACa,SAAT,GAAqB;AACnBZ,EAAAA,UAAU,EAAEa,sBAAUC,MADH;AAEnBzB,EAAAA,IAAI,EAAEwB,sBAAUC,MAFG;AAGnBhC,EAAAA,CAAC,EAAE+B,sBAAUC,MAHM;AAInBjC,EAAAA,SAAS,EAAEgC,sBAAUC,MAJF;AAKnBb,EAAAA,IAAI,EAAEY,sBAAUC;AALG,CAArB;eAQef,Q","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport DragDropTile from './choice';\n\nexport const onValueChange = (nodeProps, n, value) => {\n const val = nodeProps.editor.value;\n const change = val.change();\n\n change.setNodeByKey(n.key, {\n data: {\n ...value,\n index: n.data.get('index')\n }\n });\n\n nodeProps.editor.props.onChange(change, () => {\n nodeProps.editor.props.onEditingDone();\n });\n};\n\nexport const onRemoveResponse = (nodeProps, value) => {\n const val = nodeProps.editor.value;\n const change = val.change();\n const dragInTheBlank = val.document.findDescendant(\n n => 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"],"file":"index.js"}
|
|
@@ -16,7 +16,7 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
16
16
|
var ExplicitConstructedResponse = function ExplicitConstructedResponse(props) {
|
|
17
17
|
var attributes = props.attributes,
|
|
18
18
|
value = props.value;
|
|
19
|
-
return _react["default"].createElement("span", _extends({}, attributes, {
|
|
19
|
+
return /*#__PURE__*/_react["default"].createElement("span", _extends({}, attributes, {
|
|
20
20
|
style: {
|
|
21
21
|
display: 'inline-flex',
|
|
22
22
|
minHeight: '50px',
|
|
@@ -25,7 +25,7 @@ var ExplicitConstructedResponse = function ExplicitConstructedResponse(props) {
|
|
|
25
25
|
margin: '0 5px',
|
|
26
26
|
cursor: 'pointer'
|
|
27
27
|
}
|
|
28
|
-
}), _react["default"].createElement("div", {
|
|
28
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
29
29
|
style: {
|
|
30
30
|
display: 'inline-flex',
|
|
31
31
|
minWidth: '178px',
|
|
@@ -46,7 +46,7 @@ var ExplicitConstructedResponse = function ExplicitConstructedResponse(props) {
|
|
|
46
46
|
|
|
47
47
|
ExplicitConstructedResponse.propTypes = {
|
|
48
48
|
attributes: _propTypes["default"].object,
|
|
49
|
-
value: _propTypes["default"].
|
|
49
|
+
value: _propTypes["default"].string
|
|
50
50
|
};
|
|
51
51
|
var _default = ExplicitConstructedResponse;
|
|
52
52
|
exports["default"] = _default;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/respArea/explicit-constructed-response/index.jsx"],"names":["ExplicitConstructedResponse","props","attributes","value","display","minHeight","minWidth","position","margin","cursor","height","background","border","boxSizing","borderRadius","overflow","padding","__html","propTypes","PropTypes","object"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEA,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA8B,CAAAC,KAAK,EAAI;
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/respArea/explicit-constructed-response/index.jsx"],"names":["ExplicitConstructedResponse","props","attributes","value","display","minHeight","minWidth","position","margin","cursor","height","background","border","boxSizing","borderRadius","overflow","padding","__html","propTypes","PropTypes","object","string"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAEA,IAAMA,2BAA2B,GAAG,SAA9BA,2BAA8B,CAAAC,KAAK,EAAI;AAC3C,MAAQC,UAAR,GAA8BD,KAA9B,CAAQC,UAAR;AAAA,MAAoBC,KAApB,GAA8BF,KAA9B,CAAoBE,KAApB;AAEA,sBACE,qDACMD,UADN;AAEE,IAAA,KAAK,EAAE;AACLE,MAAAA,OAAO,EAAE,aADJ;AAELC,MAAAA,SAAS,EAAE,MAFN;AAGLC,MAAAA,QAAQ,EAAE,OAHL;AAILC,MAAAA,QAAQ,EAAE,UAJL;AAKLC,MAAAA,MAAM,EAAE,OALH;AAMLC,MAAAA,MAAM,EAAE;AANH;AAFT,mBAWE;AACE,IAAA,KAAK,EAAE;AACLL,MAAAA,OAAO,EAAE,aADJ;AAELE,MAAAA,QAAQ,EAAE,OAFL;AAGLD,MAAAA,SAAS,EAAE,MAHN;AAILK,MAAAA,MAAM,EAAE,MAJH;AAKLC,MAAAA,UAAU,EAAE,MALP;AAMLC,MAAAA,MAAM,EAAE,mBANH;AAOLC,MAAAA,SAAS,EAAE,YAPN;AAQLC,MAAAA,YAAY,EAAE,KART;AASLC,MAAAA,QAAQ,EAAE,QATL;AAULC,MAAAA,OAAO,EAAE;AAVJ,KADT;AAaE,IAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM,EAAEd,KAAK,IAAI;AADM;AAb3B,IAXF,CADF;AA+BD,CAlCD;;AAoCAH,2BAA2B,CAACkB,SAA5B,GAAwC;AACtChB,EAAAA,UAAU,EAAEiB,sBAAUC,MADgB;AAEtCjB,EAAAA,KAAK,EAAEgB,sBAAUE;AAFqB,CAAxC;eAKerB,2B","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\n\nconst ExplicitConstructedResponse = props => {\n const { attributes, value } = 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 #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"],"file":"index.js"}
|
|
@@ -17,9 +17,9 @@ var _styles = require("@material-ui/core/styles");
|
|
|
17
17
|
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
19
19
|
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
21
|
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
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) { _defineProperty(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
|
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; }
|
|
25
25
|
|
|
@@ -43,7 +43,7 @@ var Chevron = function Chevron(props) {
|
|
|
43
43
|
var direction = props.direction,
|
|
44
44
|
style = props.style;
|
|
45
45
|
var rotate = getRotate(direction);
|
|
46
|
-
return _react["default"].createElement(_ChevronRight["default"], {
|
|
46
|
+
return /*#__PURE__*/_react["default"].createElement(_ChevronRight["default"], {
|
|
47
47
|
style: _objectSpread({
|
|
48
48
|
transform: "rotate(".concat(rotate, "deg)")
|
|
49
49
|
}, style)
|
|
@@ -58,13 +58,13 @@ Chevron.propTypes = {
|
|
|
58
58
|
|
|
59
59
|
var GripIcon = function GripIcon(_ref) {
|
|
60
60
|
var style = _ref.style;
|
|
61
|
-
return _react["default"].createElement("span", {
|
|
61
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
62
62
|
style: style
|
|
63
|
-
}, _react["default"].createElement(_MoreVert["default"], {
|
|
63
|
+
}, /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], {
|
|
64
64
|
style: {
|
|
65
65
|
margin: '0 -16px'
|
|
66
66
|
}
|
|
67
|
-
}), _react["default"].createElement(_MoreVert["default"], null));
|
|
67
|
+
}), /*#__PURE__*/_react["default"].createElement(_MoreVert["default"], null));
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
exports.GripIcon = GripIcon;
|
|
@@ -85,7 +85,7 @@ var ToolbarIcon = (0, _styles.withStyles)({
|
|
|
85
85
|
}
|
|
86
86
|
})(function (_ref2) {
|
|
87
87
|
var classes = _ref2.classes;
|
|
88
|
-
return _react["default"].createElement("div", {
|
|
88
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
89
89
|
className: classes.icon
|
|
90
90
|
}, "+ Response Area");
|
|
91
91
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/respArea/icons/index.jsx"],"names":["getRotate","direction","Chevron","props","style","rotate","transform","propTypes","PropTypes","string","object","GripIcon","margin","ToolbarIcon","icon","fontFamily","fontSize","fontWeight","lineHeight","position","top","width","height","whiteSpace","classes"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAAAC,SAAS,EAAI;AAC7B,UAAQA,SAAR;AACE,SAAK,MAAL;AACE,aAAO,EAAP;;AACF,SAAK,IAAL;AACE,aAAO,CAAC,EAAR;;AACF,SAAK,MAAL;AACE,aAAO,GAAP;;AACF;AACE,aAAO,CAAP;AARJ;AAUD,CAXD;;AAaO,IAAMC,OAAO,GAAG,SAAVA,OAAU,CAAAC,KAAK,EAAI;
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/respArea/icons/index.jsx"],"names":["getRotate","direction","Chevron","props","style","rotate","transform","propTypes","PropTypes","string","object","GripIcon","margin","ToolbarIcon","icon","fontFamily","fontSize","fontWeight","lineHeight","position","top","width","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AE,MAHR;AAIJC,IAAAA,UAAU,EAAE,MAJR;AAKJC,IAAAA,QAAQ,EAAE,UALN;AAMJC,IAAAA,GAAG,EAAE,KAND;AAOJC,IAAAA,KAAK,EAAE,OAPH;AAQJC,IAAAA,MAAM,EAAE,MARJ;AASJC,IAAAA,UAAU,EAAE;AATR;AAD8B,CAAX,EAYxB;AAAA,MAAGC,OAAH,SAAGA,OAAH;AAAA,sBAAiB;AAAK,IAAA,SAAS,EAAEA,OAAO,CAACV;AAAxB,uBAAjB;AAAA,CAZwB,CAApB","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport ChevronRight from '@material-ui/icons/ChevronRight';\nimport MoreVert from '@material-ui/icons/MoreVert';\nimport { withStyles } from '@material-ui/core/styles';\n\nconst getRotate = direction => {\n switch (direction) {\n case 'down':\n return 90;\n 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"],"file":"index.js"}
|
|
@@ -26,11 +26,16 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
26
26
|
|
|
27
27
|
var log = (0, _debug["default"])('@pie-lib:editable-html:plugins:respArea');
|
|
28
28
|
var lastIndexMap = {};
|
|
29
|
-
var
|
|
29
|
+
var elTypesMap = {
|
|
30
|
+
'inline-dropdown': 'inline_dropdown',
|
|
31
|
+
'explicit-constructed-response': 'explicit_constructed_response',
|
|
32
|
+
'drag-in-the-blank': 'drag_in_the_blank'
|
|
33
|
+
};
|
|
34
|
+
var elTypesArray = Object.values(elTypesMap);
|
|
30
35
|
|
|
31
36
|
function ResponseAreaPlugin(opts) {
|
|
32
37
|
var toolbar = {
|
|
33
|
-
icon: _react["default"].createElement(_icons.ToolbarIcon, null),
|
|
38
|
+
icon: /*#__PURE__*/_react["default"].createElement(_icons.ToolbarIcon, null),
|
|
34
39
|
buttonStyles: {
|
|
35
40
|
margin: '0 20px 0 auto'
|
|
36
41
|
},
|
|
@@ -98,7 +103,7 @@ function ResponseAreaPlugin(opts) {
|
|
|
98
103
|
|
|
99
104
|
if (n.type === 'explicit_constructed_response') {
|
|
100
105
|
var data = n.data.toJSON();
|
|
101
|
-
return _react["default"].createElement(_explicitConstructedResponse["default"], {
|
|
106
|
+
return /*#__PURE__*/_react["default"].createElement(_explicitConstructedResponse["default"], {
|
|
102
107
|
attributes: attributes,
|
|
103
108
|
value: data.value
|
|
104
109
|
});
|
|
@@ -107,7 +112,7 @@ function ResponseAreaPlugin(opts) {
|
|
|
107
112
|
if (n.type === 'drag_in_the_blank') {
|
|
108
113
|
var _data = n.data.toJSON();
|
|
109
114
|
|
|
110
|
-
return _react["default"].createElement(_dragInTheBlank["default"], {
|
|
115
|
+
return /*#__PURE__*/_react["default"].createElement(_dragInTheBlank["default"], {
|
|
111
116
|
attributes: attributes,
|
|
112
117
|
data: _data,
|
|
113
118
|
n: n,
|
|
@@ -119,13 +124,13 @@ function ResponseAreaPlugin(opts) {
|
|
|
119
124
|
if (n.type === 'inline_dropdown') {
|
|
120
125
|
var _data2 = n.data.toJSON();
|
|
121
126
|
|
|
122
|
-
return _react["default"].createElement(_inlineDropdown["default"], {
|
|
127
|
+
return /*#__PURE__*/_react["default"].createElement(_inlineDropdown["default"], {
|
|
123
128
|
attributes: attributes,
|
|
124
129
|
selectedItem: _data2.value
|
|
125
130
|
});
|
|
126
131
|
}
|
|
127
132
|
},
|
|
128
|
-
onChange: function onChange(change) {
|
|
133
|
+
onChange: function onChange(change, editor) {
|
|
129
134
|
var type = opts.type.replace(/-/g, '_');
|
|
130
135
|
|
|
131
136
|
if ((0, _isUndefined["default"])(lastIndexMap[type])) {
|
|
@@ -140,6 +145,28 @@ function ResponseAreaPlugin(opts) {
|
|
|
140
145
|
}
|
|
141
146
|
});
|
|
142
147
|
}
|
|
148
|
+
|
|
149
|
+
if (!editor.value) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
var isOfCurrentType = function isOfCurrentType(d) {
|
|
154
|
+
return d.type === opts.type || d.type === elTypesMap[opts.type];
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
var currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);
|
|
158
|
+
var oldRespAreaList = editor.value.document.filterDescendants(isOfCurrentType);
|
|
159
|
+
var arrayToFilter = oldRespAreaList.size > currentRespAreaList.size ? oldRespAreaList : currentRespAreaList;
|
|
160
|
+
var arrayToUseForFilter = arrayToFilter === oldRespAreaList ? currentRespAreaList : oldRespAreaList;
|
|
161
|
+
var elementsWithChangedStatus = arrayToFilter.filter(function (d) {
|
|
162
|
+
return !arrayToUseForFilter.find(function (e) {
|
|
163
|
+
return e.data.get('index') === d.data.get('index');
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
if (elementsWithChangedStatus.size) {
|
|
168
|
+
opts.onHandleAreaChange(elementsWithChangedStatus);
|
|
169
|
+
}
|
|
143
170
|
},
|
|
144
171
|
onDrop: function onDrop(event, change, editor) {
|
|
145
172
|
var closestEl = event.target.closest('[data-key]');
|
|
@@ -204,7 +231,7 @@ var serialization = {
|
|
|
204
231
|
case 'inline_dropdown':
|
|
205
232
|
{
|
|
206
233
|
var data = object.data.toJSON();
|
|
207
|
-
return _react["default"].createElement("span", {
|
|
234
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
208
235
|
"data-type": "inline_dropdown",
|
|
209
236
|
"data-index": data.index,
|
|
210
237
|
"data-value": data.value
|
|
@@ -215,7 +242,7 @@ var serialization = {
|
|
|
215
242
|
{
|
|
216
243
|
var _data3 = object.data.toJSON();
|
|
217
244
|
|
|
218
|
-
return _react["default"].createElement("span", {
|
|
245
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
219
246
|
"data-type": "explicit_constructed_response",
|
|
220
247
|
"data-index": _data3.index,
|
|
221
248
|
"data-value": _data3.value
|
|
@@ -226,7 +253,7 @@ var serialization = {
|
|
|
226
253
|
{
|
|
227
254
|
var _data4 = object.data.toJSON();
|
|
228
255
|
|
|
229
|
-
return _react["default"].createElement("span", {
|
|
256
|
+
return /*#__PURE__*/_react["default"].createElement("span", {
|
|
230
257
|
"data-type": "drag_in_the_blank",
|
|
231
258
|
"data-index": _data4.index,
|
|
232
259
|
"data-id": _data4.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/respArea/index.jsx"],"names":["log","lastIndexMap","elTypesArray","ResponseAreaPlugin","opts","toolbar","icon","buttonStyles","margin","onClick","value","onChange","change","type","replace","prevIndex","newIndex","newInline","selection","startKey","endKey","insertInline","lastText","document","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","forEachDescendant","d","parseInt","get","onDrop","event","editor","closestEl","target","closest","inline","findDescendant","dataset","serialization","deserialize","el","id","inTable","serialize"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,GAAG,GAAG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,QAAtB,EAAgC;AAC9B;AACD;;AAED,YAAQA,MAAM,CAAC5B,IAAf;AACE,WAAK,iBAAL;AAAwB;AACtB,cAAM2C,IAAI,GAAGf,MAAM,CAACe,IAAP,CAAYC,MAAZ,EAAb;AAEA,iBAAO;AAAM,yBAAU,iBAAhB;AAAkC,0BAAYD,IAAI,CAAC5B,KAAnD;AAA0D,0BAAY4B,IAAI,CAAC9C;AAA3E,YAAP;AACD;;AACD,WAAK,+BAAL;AAAsC;AACpC,cAAM8C,MAAI,GAAGf,MAAM,CAACe,IAAP,CAAYC,MAAZ,EAAb;;AAEA,iBACE;AACE,yBAAU,+BADZ;AAEE,0BAAYD,MAAI,CAAC5B,KAFnB;AAGE,0BAAY4B,MAAI,CAAC9C;AAHnB,YADF;AAOD;;AACD,WAAK,mBAAL;AAA0B;AACxB,cAAM8C,MAAI,GAAGf,MAAM,CAACe,IAAP,CAAYC,MAAZ,EAAb;;AAEA,iBACE;AACE,yBAAU,mBADZ;AAEE,0BAAYD,MAAI,CAAC5B,KAFnB;AAGE,uBAAS4B,MAAI,CAACkB,EAHhB;AAIE,0BAAYlB,MAAI,CAAC9C,KAJnB;AAKE,6BAAe8C,MAAI,CAACmB;AALtB,YADF;AASD;AA7BH;AA+BD;AA3E0B,CAAtB","sourcesContent":["import React from 'react';\nimport debug from 'debug';\nimport isUndefined from 'lodash/isUndefined';\n\nimport InlineDropdown from './inline-dropdown';\nimport DragInTheBlank from './drag-in-the-blank';\nimport ExplicitConstructedResponse from './explicit-constructed-response';\nimport { getDefaultElement } from './utils';\nimport { ToolbarIcon } from './icons';\n\nconst log = debug('@pie-lib:editable-html:plugins:respArea');\n\nconst lastIndexMap = {};\nconst elTypesArray = ['inline_dropdown', 'explicit_constructed_response', 'drag_in_the_blank'];\n\nexport default function ResponseAreaPlugin(opts) {\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 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\n return <ExplicitConstructedResponse attributes={attributes} value={data.value} />;\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) {\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 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"],"file":"index.js"}
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/respArea/index.jsx"],"names":["log","lastIndexMap","elTypesMap","elTypesArray","Object","values","ResponseAreaPlugin","opts","toolbar","icon","buttonStyles","margin","onClick","value","onChange","change","type","replace","prevIndex","newIndex","newInline","selection","startKey","endKey","insertInline","lastText","document","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","editor","forEachDescendant","d","parseInt","get","isOfCurrentType","currentRespAreaList","filterDescendants","oldRespAreaList","arrayToFilter","size","arrayToUseForFilter","elementsWithChangedStatus","find","onHandleAreaChange","onDrop","event","closestEl","target","closest","inline","findDescendant","dataset","serialization","deserialize","el","id","inTable","serialize"],"mappings":";;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,yCAAN,CAAZ;AAEA,IAAMC,YAAY,GAAG,EAArB;AACA,IAAMC,UAAU,GAAG;AACjB,qBAAmB,iBADF;AAEjB,mCAAiC,+BAFhB;AAGjB,uBAAqB;AAHJ,CAAnB;AAKA,IAAMC,YAAY,GAAGC,MAAM,CAACC,MAAP,CAAcH,UAAd,CAArB;;AAEe,SAASI,kBAAT,CAA4BC,IAA5B,EAAkC;AAC/C,MAAMC,OAAO,GAAG;AACdC,IAAAA,IAAI,eAAE,gCAAC,kBAAD,OADQ;AAEdC,IAAAA,YAAY,EAAE;AACZC,MAAAA,MAAM,EAAE;AADI,KAFA;AAKdC,IAAAA,OAAO,EAAE,iBAACC,KAAD,EAAQC,QAAR,EAAqB;AAC5Bd,MAAAA,GAAG,CAAC,mBAAD,CAAH;AACA,UAAMe,MAAM,GAAGF,KAAK,CAACE,MAAN,EAAf;AACA,UAAMC,IAAI,GAAGT,IAAI,CAACS,IAAL,CAAUC,OAAV,CAAkB,IAAlB,EAAwB,GAAxB,CAAb;AACA,UAAMC,SAAS,GAAGjB,YAAY,CAACe,IAAD,CAA9B;AACA,UAAMG,QAAQ,GAAGD,S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+BD;AA3E0B,CAAtB","sourcesContent":["import React from 'react';\nimport debug from 'debug';\nimport isUndefined from 'lodash/isUndefined';\n\nimport InlineDropdown from './inline-dropdown';\nimport DragInTheBlank from './drag-in-the-blank';\nimport ExplicitConstructedResponse from './explicit-constructed-response';\nimport { getDefaultElement } from './utils';\nimport { ToolbarIcon } from './icons';\n\nconst log = debug('@pie-lib:editable-html:plugins:respArea');\n\nconst lastIndexMap = {};\nconst elTypesMap = {\n 'inline-dropdown': 'inline_dropdown',\n 'explicit-constructed-response': 'explicit_constructed_response',\n 'drag-in-the-blank': 'drag_in_the_blank'\n};\nconst elTypesArray = Object.values(elTypesMap);\n\nexport default function ResponseAreaPlugin(opts) {\n const 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 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\n return <ExplicitConstructedResponse attributes={attributes} value={data.value} />;\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 isOfCurrentType = d => d.type === opts.type || d.type === elTypesMap[opts.type];\n const currentRespAreaList = change.value.document.filterDescendants(isOfCurrentType);\n const oldRespAreaList = editor.value.document.filterDescendants(isOfCurrentType);\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) {\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"],"file":"index.js"}
|
|
@@ -21,14 +21,14 @@ var InlineDropdown = function InlineDropdown(_ref) {
|
|
|
21
21
|
// TODO: Investigate
|
|
22
22
|
// Needed because items with values inside have different positioning for some reason
|
|
23
23
|
var html = selectedItem || '<div> </div>';
|
|
24
|
-
return _react["default"].createElement("span", _extends({}, attributes, {
|
|
24
|
+
return /*#__PURE__*/_react["default"].createElement("span", _extends({}, attributes, {
|
|
25
25
|
style: {
|
|
26
26
|
display: 'inline-flex',
|
|
27
27
|
height: '50px',
|
|
28
28
|
margin: '0 5px',
|
|
29
29
|
cursor: 'pointer'
|
|
30
30
|
}
|
|
31
|
-
}), _react["default"].createElement("div", {
|
|
31
|
+
}), /*#__PURE__*/_react["default"].createElement("div", {
|
|
32
32
|
style: {
|
|
33
33
|
display: 'inline-flex',
|
|
34
34
|
minWidth: '178px',
|
|
@@ -39,7 +39,7 @@ var InlineDropdown = function InlineDropdown(_ref) {
|
|
|
39
39
|
borderRadius: '3px',
|
|
40
40
|
position: 'relative'
|
|
41
41
|
}
|
|
42
|
-
}, _react["default"].createElement("div", {
|
|
42
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
43
43
|
style: {
|
|
44
44
|
flex: 1,
|
|
45
45
|
overflow: 'hidden',
|
|
@@ -51,7 +51,7 @@ var InlineDropdown = function InlineDropdown(_ref) {
|
|
|
51
51
|
dangerouslySetInnerHTML: {
|
|
52
52
|
__html: html
|
|
53
53
|
}
|
|
54
|
-
}), _react["default"].createElement(_icons.Chevron, {
|
|
54
|
+
}), /*#__PURE__*/_react["default"].createElement(_icons.Chevron, {
|
|
55
55
|
direction: "down",
|
|
56
56
|
style: {
|
|
57
57
|
position: 'absolute',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/plugins/respArea/inline-dropdown/index.jsx"],"names":["InlineDropdown","attributes","selectedItem","html","display","height","margin","cursor","minWidth","background","border","boxSizing","borderRadius","position","flex","overflow","padding","whiteSpace","textOverflow","lineHeight","__html","top","right","propTypes","PropTypes","object","oneOfType","string"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEA,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,OAAkC;AAAA,MAA/BC,UAA+B,QAA/BA,UAA+B;AAAA,MAAnBC,YAAmB,QAAnBA,YAAmB;AACvD;AACA;AACA,MAAMC,IAAI,GAAGD,YAAY,IAAI,kBAA7B;AAEA,
|
|
1
|
+
{"version":3,"sources":["../../../../src/plugins/respArea/inline-dropdown/index.jsx"],"names":["InlineDropdown","attributes","selectedItem","html","display","height","margin","cursor","minWidth","background","border","boxSizing","borderRadius","position","flex","overflow","padding","whiteSpace","textOverflow","lineHeight","__html","top","right","propTypes","PropTypes","object","oneOfType","string"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;AAEA,IAAMA,cAAc,GAAG,SAAjBA,cAAiB,OAAkC;AAAA,MAA/BC,UAA+B,QAA/BA,UAA+B;AAAA,MAAnBC,YAAmB,QAAnBA,YAAmB;AACvD;AACA;AACA,MAAMC,IAAI,GAAGD,YAAY,IAAI,kBAA7B;AAEA,sBACE,qDACMD,UADN;AAEE,IAAA,KAAK,EAAE;AACLG,MAAAA,OAAO,EAAE,aADJ;AAELC,MAAAA,MAAM,EAAE,MAFH;AAGLC,MAAAA,MAAM,EAAE,OAHH;AAILC,MAAAA,MAAM,EAAE;AAJH;AAFT,mBASE;AACE,IAAA,KAAK,EAAE;AACLH,MAAAA,OAAO,EAAE,aADJ;AAELI,MAAAA,QAAQ,EAAE,OAFL;AAGLH,MAAAA,MAAM,EAAE,MAHH;AAILI,MAAAA,UAAU,EAAE,MAJP;AAKLC,MAAAA,MAAM,EAAE,mBALH;AAMLC,MAAAA,SAAS,EAAE,YANN;AAOLC,MAAAA,YAAY,EAAE,KAPT;AAQLC,MAAAA,QAAQ,EAAE;AARL;AADT,kBAYE;AACE,IAAA,KAAK,EAAE;AACLC,MAAAA,IAAI,EAAE,CADD;AAELC,MAAAA,QAAQ,EAAE,QAFL;AAGLC,MAAAA,OAAO,EAAE,cAHJ;AAILC,MAAAA,UAAU,EAAE,QAJP;AAKLC,MAAAA,YAAY,EAAE,UALT;AAMLC,MAAAA,UAAU,EAAE;AANP,KADT;AASE,IAAA,uBAAuB,EAAE;AACvBC,MAAAA,MAAM,EAAEjB;AADe;AAT3B,IAZF,eAyBE,gCAAC,cAAD;AACE,IAAA,SAAS,EAAC,MADZ;AAEE,IAAA,KAAK,EAAE;AACLU,MAAAA,QAAQ,EAAE,UADL;AAELQ,MAAAA,GAAG,EAAE,KAFA;AAGLC,MAAAA,KAAK,EAAE;AAHF;AAFT,IAzBF,CATF,CADF;AA8CD,CAnDD;;AAqDAtB,cAAc,CAACuB,SAAf,GAA2B;AACzBtB,EAAAA,UAAU,EAAEuB,sBAAUC,MADG;AAEzBvB,EAAAA,YAAY,EAAEsB,sBAAUE,SAAV,CAAoB,CAACF,sBAAUG,MAAX,EAAmBH,sBAAUC,MAA7B,CAApB;AAFW,CAA3B;eAKezB,c","sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Chevron } from '../icons';\n\nconst InlineDropdown = ({ attributes, selectedItem }) => {\n // TODO: Investigate\n // Needed because items with values inside have different positioning for some reason\n const html = selectedItem || '<div> </div>';\n\n return (\n <span\n {...attributes}\n style={{\n display: 'inline-flex',\n height: '50px',\n margin: '0 5px',\n cursor: 'pointer'\n }}\n >\n <div\n style={{\n display: 'inline-flex',\n minWidth: '178px',\n height: '36px',\n background: '#FFF',\n border: '1px solid #C0C3CF',\n boxSizing: 'border-box',\n borderRadius: '3px',\n position: 'relative'\n }}\n >\n <div\n style={{\n flex: 1,\n overflow: 'hidden',\n padding: '0 25px 0 8px',\n whiteSpace: 'nowrap',\n textOverflow: 'ellipsis',\n lineHeight: '35px'\n }}\n dangerouslySetInnerHTML={{\n __html: html\n }}\n />\n <Chevron\n direction=\"down\"\n style={{\n position: 'absolute',\n top: '5px',\n right: '5px'\n }}\n />\n </div>\n </span>\n );\n};\n\nInlineDropdown.propTypes = {\n attributes: PropTypes.object,\n selectedItem: PropTypes.oneOfType([PropTypes.string, PropTypes.object])\n};\n\nexport default InlineDropdown;\n"],"file":"index.js"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.isNumber = exports.insertSnackBar = exports.getDefaultElement = exports.defaultIDD = exports.defaultECR = exports.defaultDIB = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -29,7 +29,7 @@ var insertSnackBar = function insertSnackBar(message) {
|
|
|
29
29
|
var newEl = document.createElement('div');
|
|
30
30
|
newEl.className = 'response-area-alert';
|
|
31
31
|
|
|
32
|
-
var el = _react["default"].createElement(_Snackbar["default"], {
|
|
32
|
+
var el = /*#__PURE__*/_react["default"].createElement(_Snackbar["default"], {
|
|
33
33
|
anchorOrigin: {
|
|
34
34
|
vertical: 'top',
|
|
35
35
|
horizontal: 'center'
|
|
@@ -38,7 +38,7 @@ var insertSnackBar = function insertSnackBar(message) {
|
|
|
38
38
|
ContentProps: {
|
|
39
39
|
'aria-describedby': 'message-id'
|
|
40
40
|
},
|
|
41
|
-
message: _react["default"].createElement("span", {
|
|
41
|
+
message: /*#__PURE__*/_react["default"].createElement("span", {
|
|
42
42
|
id: "message-id"
|
|
43
43
|
}, message)
|
|
44
44
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/plugins/respArea/utils.jsx"],"names":["isNumber","val","isNaN","parseFloat","isFinite","insertSnackBar","message","prevSnacks","document","querySelectorAll","forEach","s","remove","newEl","createElement","className","el","vertical","horizontal","ReactDOM","render","body","appendChild","setTimeout","defaultECR","index","Inline","create","type","isVoid","data","defaultDIB","opts","duplicates","options","value","defaultIDD","object","getDefaultElement"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAAAC,GAAG;AAAA,SAAI,CAACC,KAAK,CAACC,UAAU,CAACF,GAAD,CAAX,CAAN,IAA2BG,QAAQ,CAACH,GAAD,CAAvC;AAAA,CAApB;;;;AAEA,IAAMI,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,OAAO,EAAI;AACvC,MAAMC,UAAU,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,sBAA1B,CAAnB;AAEAF,EAAAA,UAAU,CAACG,OAAX,CAAmB,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,MAAF,EAAJ;AAAA,GAApB;AAEA,MAAMC,KAAK,GAAGL,QAAQ,CAACM,aAAT,CAAuB,KAAvB,CAAd;AAEAD,EAAAA,KAAK,CAACE,SAAN,GAAkB,qBAAlB;;AAEA,MAAMC,EAAE,
|
|
1
|
+
{"version":3,"sources":["../../../src/plugins/respArea/utils.jsx"],"names":["isNumber","val","isNaN","parseFloat","isFinite","insertSnackBar","message","prevSnacks","document","querySelectorAll","forEach","s","remove","newEl","createElement","className","el","vertical","horizontal","ReactDOM","render","body","appendChild","setTimeout","defaultECR","index","Inline","create","type","isVoid","data","defaultDIB","opts","duplicates","options","value","defaultIDD","object","getDefaultElement"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;;;AAEO,IAAMA,QAAQ,GAAG,SAAXA,QAAW,CAAAC,GAAG;AAAA,SAAI,CAACC,KAAK,CAACC,UAAU,CAACF,GAAD,CAAX,CAAN,IAA2BG,QAAQ,CAACH,GAAD,CAAvC;AAAA,CAApB;;;;AAEA,IAAMI,cAAc,GAAG,SAAjBA,cAAiB,CAAAC,OAAO,EAAI;AACvC,MAAMC,UAAU,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,sBAA1B,CAAnB;AAEAF,EAAAA,UAAU,CAACG,OAAX,CAAmB,UAAAC,CAAC;AAAA,WAAIA,CAAC,CAACC,MAAF,EAAJ;AAAA,GAApB;AAEA,MAAMC,KAAK,GAAGL,QAAQ,CAACM,aAAT,CAAuB,KAAvB,CAAd;AAEAD,EAAAA,KAAK,CAACE,SAAN,GAAkB,qBAAlB;;AAEA,MAAMC,EAAE,gBACN,gCAAC,oBAAD;AACE,IAAA,YAAY,EAAE;AAAEC,MAAAA,QAAQ,EAAE,KAAZ;AAAmBC,MAAAA,UAAU,EAAE;AAA/B,KADhB;AAEE,IAAA,IAAI,EAAE,IAFR;AAGE,IAAA,YAAY,EAAE;AACZ,0BAAoB;AADR,KAHhB;AAME,IAAA,OAAO,eAAE;AAAM,MAAA,EAAE,EAAC;AAAT,OAAuBZ,OAAvB;AANX,I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AU,CAACC,KAAD,CAAjB;;AACF,SAAK,mBAAL;AACE,aAAOM,UAAU,CAACC,IAAD,EAAOP,KAAP,CAAjB;;AACF;AACE;AACA,aAAOW,UAAU,CAACX,KAAD,CAAjB;AAPJ;AASD,CAVM","sourcesContent":["import React from 'react';\nimport ReactDOM from 'react-dom';\nimport { Inline } from 'slate';\nimport Snackbar from '@material-ui/core/Snackbar';\n\nexport const isNumber = val => !isNaN(parseFloat(val)) && isFinite(val);\n\nexport const insertSnackBar = message => {\n const prevSnacks = document.querySelectorAll('.response-area-alert');\n\n prevSnacks.forEach(s => s.remove());\n\n const newEl = document.createElement('div');\n\n newEl.className = 'response-area-alert';\n\n const el = (\n <Snackbar\n anchorOrigin={{ vertical: 'top', horizontal: 'center' }}\n open={true}\n ContentProps={{\n 'aria-describedby': 'message-id'\n }}\n message={<span id=\"message-id\">{message}</span>}\n />\n );\n\n ReactDOM.render(el, newEl);\n\n document.body.appendChild(newEl);\n\n setTimeout(() => {\n newEl.remove();\n }, 2000);\n};\n\nexport const defaultECR = index =>\n Inline.create({\n type: 'explicit_constructed_response',\n isVoid: true,\n data: {\n index\n }\n });\n\nexport const defaultDIB = (opts, index) =>\n Inline.create({\n type: 'drag_in_the_blank',\n isVoid: true,\n data: {\n index,\n duplicates: opts.options.duplicates,\n value: null\n }\n });\n\nexport const defaultIDD = index =>\n Inline.create({\n object: 'inline',\n type: 'inline_dropdown',\n isVoid: true,\n data: {\n index\n }\n });\n\nexport const getDefaultElement = (opts, index) => {\n switch (opts.type) {\n case 'explicit-constructed-response':\n return defaultECR(index);\n case 'drag-in-the-blank':\n return defaultDIB(opts, index);\n default:\n // inline-dropdown\n return defaultIDD(index);\n }\n};\n"],"file":"utils.js"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RemoveTable = exports.
|
|
6
|
+
exports.RemoveTable = exports.RemoveRow = exports.RemoveColumn = exports.AddRow = exports.AddColumn = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
|
|
@@ -24,44 +24,44 @@ var styles = {
|
|
|
24
24
|
|
|
25
25
|
var SvgIcon = function SvgIcon(Component) {
|
|
26
26
|
return (0, _styles.withStyles)(styles)(function (props) {
|
|
27
|
-
return _react["default"].createElement("svg", {
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement("svg", {
|
|
28
28
|
xmlns: "http://www.w3.org/2000/svg",
|
|
29
29
|
version: "1.1",
|
|
30
30
|
width: "24",
|
|
31
31
|
height: "24",
|
|
32
32
|
viewBox: "0 0 24 24"
|
|
33
|
-
}, _react["default"].createElement(Component, {
|
|
33
|
+
}, /*#__PURE__*/_react["default"].createElement(Component, {
|
|
34
34
|
className: props.classes.icon
|
|
35
35
|
}));
|
|
36
36
|
});
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
var AddRow = SvgIcon(function (props) {
|
|
40
|
-
return _react["default"].createElement("path", _extends({}, props, {
|
|
40
|
+
return /*#__PURE__*/_react["default"].createElement("path", _extends({}, props, {
|
|
41
41
|
d: "M22,10A2,2 0 0,1 20,12H4A2,2 0 0,1 2,10V3H4V5H8V3H10V5H14V3H16V5H20V3H22V10M4,10H8V7H4V10M10,10H14V7H10V10M20,10V7H16V10H20M11,14H13V17H16V19H13V22H11V19H8V17H11V14Z"
|
|
42
42
|
}));
|
|
43
43
|
});
|
|
44
44
|
exports.AddRow = AddRow;
|
|
45
45
|
var RemoveRow = SvgIcon(function (props) {
|
|
46
|
-
return _react["default"].createElement("path", _extends({}, props, {
|
|
46
|
+
return /*#__PURE__*/_react["default"].createElement("path", _extends({}, props, {
|
|
47
47
|
d: "M9.41,13L12,15.59L14.59,13L16,14.41L13.41,17L16,19.59L14.59,21L12,18.41L9.41,21L8,19.59L10.59,17L8,14.41L9.41,13M22,9A2,2 0 0,1 20,11H4A2,2 0 0,1 2,9V6A2,2 0 0,1 4,4H20A2,2 0 0,1 22,6V9M4,9H8V6H4V9M10,9H14V6H10V9M16,9H20V6H16V9Z"
|
|
48
48
|
}));
|
|
49
49
|
});
|
|
50
50
|
exports.RemoveRow = RemoveRow;
|
|
51
51
|
var AddColumn = SvgIcon(function (props) {
|
|
52
|
-
return _react["default"].createElement("path", _extends({}, props, {
|
|
52
|
+
return /*#__PURE__*/_react["default"].createElement("path", _extends({}, props, {
|
|
53
53
|
d: "M11,2A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H2V2H11M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M15,11H18V8H20V11H23V13H20V16H18V13H15V11Z"
|
|
54
54
|
}));
|
|
55
55
|
});
|
|
56
56
|
exports.AddColumn = AddColumn;
|
|
57
57
|
var RemoveColumn = SvgIcon(function (props) {
|
|
58
|
-
return _react["default"].createElement("path", _extends({}, props, {
|
|
58
|
+
return /*#__PURE__*/_react["default"].createElement("path", _extends({}, props, {
|
|
59
59
|
d: "M4,2H11A2,2 0 0,1 13,4V20A2,2 0 0,1 11,22H4A2,2 0 0,1 2,20V4A2,2 0 0,1 4,2M4,10V14H11V10H4M4,16V20H11V16H4M4,4V8H11V4H4M17.59,12L15,9.41L16.41,8L19,10.59L21.59,8L23,9.41L20.41,12L23,14.59L21.59,16L19,13.41L16.41,16L15,14.59L17.59,12Z"
|
|
60
60
|
}));
|
|
61
61
|
});
|
|
62
62
|
exports.RemoveColumn = RemoveColumn;
|
|
63
63
|
var RemoveTable = SvgIcon(function (props) {
|
|
64
|
-
return _react["default"].createElement("path", _extends({}, props, {
|
|
64
|
+
return /*#__PURE__*/_react["default"].createElement("path", _extends({}, props, {
|
|
65
65
|
d: "M15.46,15.88L16.88,14.46L19,16.59L21.12,14.46L22.54,15.88L20.41,18L22.54,20.12L21.12,21.54L19,19.41L16.88,21.54L15.46,20.12L17.59,18L15.46,15.88M4,3H18A2,2 0 0,1 20,5V12.08C18.45,11.82 16.92,12.18 15.68,13H12V17H13.08C12.97,17.68 12.97,18.35 13.08,19H4A2,2 0 0,1 2,17V5A2,2 0 0,1 4,3M4,7V11H10V7H4M12,7V11H18V7H12M4,13V17H10V13H4Z"
|
|
66
66
|
}));
|
|
67
67
|
});
|