@pie-element/extended-text-entry 14.0.0-next.42 → 14.1.0-next.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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry-configure",
3
3
  "private": true,
4
- "version": "12.0.0-beta.1",
4
+ "version": "12.1.0-next.0",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
@@ -13,11 +13,11 @@
13
13
  "@mui/icons-material": "^7.3.4",
14
14
  "@mui/material": "^7.3.4",
15
15
  "@pie-framework/pie-configure-events": "^1.3.0",
16
- "@pie-lib/config-ui": "12.1.1-next.0",
17
- "@pie-lib/editable-html-tip-tap": "1.1.1-next.0",
18
- "lodash": "^4.17.15",
16
+ "@pie-lib/config-ui": "12.1.1-next.3",
17
+ "@pie-lib/editable-html-tip-tap": "1.1.1-next.3",
18
+ "lodash-es": "^4.17.23",
19
19
  "prop-types": "^15.6.2",
20
- "react": "18.2.0",
21
- "react-dom": "18.2.0"
20
+ "react": "18.3.1",
21
+ "react-dom": "18.3.1"
22
22
  }
23
23
  }
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry-controller",
3
3
  "private": true,
4
- "version": "8.0.0-beta.1",
4
+ "version": "8.1.0-next.0",
5
5
  "description": "",
6
6
  "main": "lib/index.js",
7
7
  "module": "src/index.js",
8
8
  "dependencies": {
9
- "@pie-lib/feedback": "1.1.1-next.0"
9
+ "@pie-lib/feedback": "1.1.1-next.1"
10
10
  },
11
11
  "scripts": {
12
12
  "test": "echo \"Error: no test specified\" && exit 1"
package/lib/main.js CHANGED
@@ -8,7 +8,7 @@ exports.default = exports.Main = void 0;
8
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
9
  var _react = _interopRequireDefault(require("react"));
10
10
  var _propTypes = _interopRequireDefault(require("prop-types"));
11
- var _debounce = _interopRequireDefault(require("lodash/debounce"));
11
+ var _lodashEs = require("lodash-es");
12
12
  var _debug = _interopRequireDefault(require("debug"));
13
13
  var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
14
14
  var _styles = require("@mui/material/styles");
@@ -50,8 +50,8 @@ const SrOnly = (0, _styles.styled)('h2')({
50
50
  class Main extends _react.default.Component {
51
51
  constructor(...args) {
52
52
  super(...args);
53
- (0, _defineProperty2.default)(this, "changeSessionValue", (0, _debounce.default)(this.props.onValueChange, 1500));
54
- (0, _defineProperty2.default)(this, "changeSessionComment", (0, _debounce.default)(this.props.onCommentChange, 1500));
53
+ (0, _defineProperty2.default)(this, "changeSessionValue", (0, _lodashEs.debounce)(this.props.onValueChange, 1500));
54
+ (0, _defineProperty2.default)(this, "changeSessionComment", (0, _lodashEs.debounce)(this.props.onCommentChange, 1500));
55
55
  }
56
56
  render() {
57
57
  const {
package/lib/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_debounce","_debug","_Typography","_styles","_editableHtmlTipTap","_renderUi","_annotationEditor","log","debug","MainContainer","styled","UiLayout","backgroundColor","color","background","text","StyledPrompt","Typography","theme","width","marginBottom","spacing","fontSize","TeacherInstructions","Editor","EditableHtml","borderRadius","SrOnly","position","left","top","height","overflow","Main","React","Component","constructor","args","_defineProperty2","default","debounce","props","onValueChange","onCommentChange","render","model","session","onAnnotationsChange","animationsDisabled","annotatorMode","customKeys","dimensions","disabled","disabledAnnotator","equationEditor","extraCSSRules","feedback","mathInput","playersToolbarPosition","predefinedAnnotations","prompt","spanishInput","specialInput","spellCheckEnabled","teacherInstructions","annotations","comment","value","maxHeight","toolbarOpts","teacherInstructionsDiv","createElement","PreviewPrompt","defaultClassName","languageCharactersProps","push","language","ref","containerRef","Collapsible","labels","hidden","visible","component","onChange","changeSessionComment","disabledMath","keypadMode","className","changeSessionValue","markup","maxWidth","toString","minWidth","minHeight","highlightShape","spellCheck","charactersLimit","autoWidthToolbar","pluginProps","math","controlledKeypadMode","video","audio","table","textAlign","separateParagraphs","ul_list","ol_list","Feedback","correctness","exports","PropTypes","func","isRequired","object","shape","string","array","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport debounce from 'lodash/debounce';\nimport debug from 'debug';\n\nimport Typography from '@mui/material/Typography';\nimport { styled } from '@mui/material/styles';\n\nimport EditableHtml from '@pie-lib/editable-html-tip-tap';\nimport { color, Feedback, Collapsible, PreviewPrompt, UiLayout } from '@pie-lib/render-ui';\n\nimport AnnotationEditor from './annotation/annotation-editor';\n\nconst log = debug('@pie-ui:extended-text-entry');\n\nconst MainContainer = styled(UiLayout)({\n backgroundColor: color.background(),\n color: color.text(),\n});\n\nconst StyledPrompt = styled(Typography)(({ theme }) => ({\n width: '100%',\n color: color.text(),\n marginBottom: theme.spacing(2),\n fontSize: 'inherit',\n}));\n\nconst TeacherInstructions = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(2),\n}));\n\nconst Editor = styled(EditableHtml)(({ theme }) => ({\n marginBottom: theme.spacing(2),\n borderRadius: '4px',\n}));\n\nconst SrOnly = styled('h2')({\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n onValueChange: PropTypes.func.isRequired,\n onAnnotationsChange: PropTypes.func.isRequired,\n onCommentChange: PropTypes.func.isRequired,\n model: PropTypes.object,\n session: PropTypes.shape({\n value: PropTypes.string,\n annotations: PropTypes.array,\n comment: PropTypes.string,\n }).isRequired,\n };\n\n changeSessionValue = debounce(this.props.onValueChange, 1500);\n\n changeSessionComment = debounce(this.props.onCommentChange, 1500);\n\n render() {\n const { model, session, onAnnotationsChange } = this.props;\n const {\n animationsDisabled,\n annotatorMode,\n customKeys,\n dimensions,\n disabled,\n disabledAnnotator,\n equationEditor,\n extraCSSRules,\n feedback,\n mathInput,\n playersToolbarPosition,\n predefinedAnnotations,\n prompt,\n spanishInput,\n specialInput,\n spellCheckEnabled,\n teacherInstructions,\n } = model;\n const { annotations, comment, value } = session;\n const { width, height } = dimensions || {};\n const maxHeight = '40vh';\n const toolbarOpts = { position: playersToolbarPosition === 'top' ? 'top' : 'bottom' };\n\n log('[render] disabled? ', disabled);\n\n const teacherInstructionsDiv = (\n <PreviewPrompt defaultClassName=\"teacher-instructions\" prompt={teacherInstructions} />\n );\n\n const languageCharactersProps = [];\n\n if (spanishInput) {\n languageCharactersProps.push({ language: 'spanish' });\n }\n\n if (specialInput) {\n languageCharactersProps.push({ language: 'special' });\n }\n\n return (\n <MainContainer\n extraCSSRules={extraCSSRules}\n ref={(ref) => {\n this.containerRef = ref;\n }}\n >\n <SrOnly>Constructed Response Question</SrOnly>\n\n {teacherInstructions && (\n <TeacherInstructions>\n {!animationsDisabled ? (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n ) : (\n teacherInstructionsDiv\n )}\n </TeacherInstructions>\n )}\n\n {prompt && (\n <StyledPrompt component={'span'}>\n <PreviewPrompt defaultClassName=\"prompt\" prompt={model.prompt} />\n </StyledPrompt>\n )}\n\n {annotatorMode ? (\n <AnnotationEditor\n text={value || ''}\n annotations={annotations || []}\n comment={comment || ''}\n predefinedAnnotations={predefinedAnnotations || []}\n onChange={onAnnotationsChange}\n onCommentChange={this.changeSessionComment}\n width={width}\n height={height}\n maxHeight={maxHeight}\n disabled={disabledAnnotator}\n disabledMath={!mathInput}\n customKeys={customKeys}\n keypadMode={equationEditor}\n />\n ) : (\n <Editor\n className=\"response-area-editor\"\n onChange={this.changeSessionValue}\n markup={value || ''}\n maxWidth={width && width.toString()}\n minWidth={'100px'}\n minHeight={height && height.toString()}\n maxHeight={maxHeight}\n disabled={disabled}\n highlightShape={true}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n charactersLimit={50000}\n autoWidthToolbar\n pluginProps={{\n math: {\n disabled: !mathInput,\n customKeys: this.props.model.customKeys,\n keypadMode: this.props.model.equationEditor,\n controlledKeypadMode: false,\n },\n video: {\n disabled: true,\n },\n audio: {\n disabled: true,\n },\n table: {\n disabled: true,\n },\n textAlign: {\n disabled: true,\n },\n separateParagraphs: { disabled: false },\n ul_list: { disabled: true },\n ol_list: { disabled: true },\n }}\n languageCharactersProps={languageCharactersProps}\n />\n )}\n\n {feedback && <Feedback correctness=\"correct\" feedback={feedback} />}\n </MainContainer>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,mBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,iBAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA,MAAMS,GAAG,GAAG,IAAAC,cAAK,EAAC,6BAA6B,CAAC;AAEhD,MAAMC,aAAa,GAAG,IAAAC,cAAM,EAACC,kBAAQ,CAAC,CAAC;EACrCC,eAAe,EAAEC,eAAK,CAACC,UAAU,CAAC,CAAC;EACnCD,KAAK,EAAEA,eAAK,CAACE,IAAI,CAAC;AACpB,CAAC,CAAC;AAEF,MAAMC,YAAY,GAAG,IAAAN,cAAM,EAACO,mBAAU,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACtDC,KAAK,EAAE,MAAM;EACbN,KAAK,EAAEA,eAAK,CAACE,IAAI,CAAC,CAAC;EACnBK,YAAY,EAAEF,KAAK,CAACG,OAAO,CAAC,CAAC,CAAC;EAC9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ACC,IAAI,CAACC,UAAU;EAC9CvE,eAAe,EAAEqE,kBAAS,CAACC,IAAI,CAACC,UAAU;EAC1CrE,KAAK,EAAEmE,kBAAS,CAACG,MAAM;EACvBrE,OAAO,EAAEkE,kBAAS,CAACI,KAAK,CAAC;IACvBjD,KAAK,EAAE6C,kBAAS,CAACK,MAAM;IACvBpD,WAAW,EAAE+C,kBAAS,CAACM,KAAK;IAC5BpD,OAAO,EAAE8C,kBAAS,CAACK;EACrB,CAAC,CAAC,CAACH;AACL,CAAC;AAAA,IAAAK,QAAA,GAAAR,OAAA,CAAAxE,OAAA,GA6IYN,IAAI","ignoreList":[]}
1
+ {"version":3,"file":"main.js","names":["_react","_interopRequireDefault","require","_propTypes","_lodashEs","_debug","_Typography","_styles","_editableHtmlTipTap","_renderUi","_annotationEditor","log","debug","MainContainer","styled","UiLayout","backgroundColor","color","background","text","StyledPrompt","Typography","theme","width","marginBottom","spacing","fontSize","TeacherInstructions","Editor","EditableHtml","borderRadius","SrOnly","position","left","top","height","overflow","Main","React","Component","constructor","args","_defineProperty2","default","debounce","props","onValueChange","onCommentChange","render","model","session","onAnnotationsChange","animationsDisabled","annotatorMode","customKeys","dimensions","disabled","disabledAnnotator","equationEditor","extraCSSRules","feedback","mathInput","playersToolbarPosition","predefinedAnnotations","prompt","spanishInput","specialInput","spellCheckEnabled","teacherInstructions","annotations","comment","value","maxHeight","toolbarOpts","teacherInstructionsDiv","createElement","PreviewPrompt","defaultClassName","languageCharactersProps","push","language","ref","containerRef","Collapsible","labels","hidden","visible","component","onChange","changeSessionComment","disabledMath","keypadMode","className","changeSessionValue","markup","maxWidth","toString","minWidth","minHeight","highlightShape","spellCheck","charactersLimit","autoWidthToolbar","pluginProps","math","controlledKeypadMode","video","audio","table","textAlign","separateParagraphs","ul_list","ol_list","Feedback","correctness","exports","PropTypes","func","isRequired","object","shape","string","array","_default"],"sources":["../src/main.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { debounce } from 'lodash-es';\nimport debug from 'debug';\n\nimport Typography from '@mui/material/Typography';\nimport { styled } from '@mui/material/styles';\n\nimport EditableHtml from '@pie-lib/editable-html-tip-tap';\nimport { color, Feedback, Collapsible, PreviewPrompt, UiLayout } from '@pie-lib/render-ui';\n\nimport AnnotationEditor from './annotation/annotation-editor';\n\nconst log = debug('@pie-ui:extended-text-entry');\n\nconst MainContainer = styled(UiLayout)({\n backgroundColor: color.background(),\n color: color.text(),\n});\n\nconst StyledPrompt = styled(Typography)(({ theme }) => ({\n width: '100%',\n color: color.text(),\n marginBottom: theme.spacing(2),\n fontSize: 'inherit',\n}));\n\nconst TeacherInstructions = styled('div')(({ theme }) => ({\n marginBottom: theme.spacing(2),\n}));\n\nconst Editor = styled(EditableHtml)(({ theme }) => ({\n marginBottom: theme.spacing(2),\n borderRadius: '4px',\n}));\n\nconst SrOnly = styled('h2')({\n position: 'absolute',\n left: '-10000px',\n top: 'auto',\n width: '1px',\n height: '1px',\n overflow: 'hidden',\n});\n\nexport class Main extends React.Component {\n static propTypes = {\n onValueChange: PropTypes.func.isRequired,\n onAnnotationsChange: PropTypes.func.isRequired,\n onCommentChange: PropTypes.func.isRequired,\n model: PropTypes.object,\n session: PropTypes.shape({\n value: PropTypes.string,\n annotations: PropTypes.array,\n comment: PropTypes.string,\n }).isRequired,\n };\n\n changeSessionValue = debounce(this.props.onValueChange, 1500);\n\n changeSessionComment = debounce(this.props.onCommentChange, 1500);\n\n render() {\n const { model, session, onAnnotationsChange } = this.props;\n const {\n animationsDisabled,\n annotatorMode,\n customKeys,\n dimensions,\n disabled,\n disabledAnnotator,\n equationEditor,\n extraCSSRules,\n feedback,\n mathInput,\n playersToolbarPosition,\n predefinedAnnotations,\n prompt,\n spanishInput,\n specialInput,\n spellCheckEnabled,\n teacherInstructions,\n } = model;\n const { annotations, comment, value } = session;\n const { width, height } = dimensions || {};\n const maxHeight = '40vh';\n const toolbarOpts = { position: playersToolbarPosition === 'top' ? 'top' : 'bottom' };\n\n log('[render] disabled? ', disabled);\n\n const teacherInstructionsDiv = (\n <PreviewPrompt defaultClassName=\"teacher-instructions\" prompt={teacherInstructions} />\n );\n\n const languageCharactersProps = [];\n\n if (spanishInput) {\n languageCharactersProps.push({ language: 'spanish' });\n }\n\n if (specialInput) {\n languageCharactersProps.push({ language: 'special' });\n }\n\n return (\n <MainContainer\n extraCSSRules={extraCSSRules}\n ref={(ref) => {\n this.containerRef = ref;\n }}\n >\n <SrOnly>Constructed Response Question</SrOnly>\n\n {teacherInstructions && (\n <TeacherInstructions>\n {!animationsDisabled ? (\n <Collapsible\n labels={{ hidden: 'Show Teacher Instructions', visible: 'Hide Teacher Instructions' }}\n >\n {teacherInstructionsDiv}\n </Collapsible>\n ) : (\n teacherInstructionsDiv\n )}\n </TeacherInstructions>\n )}\n\n {prompt && (\n <StyledPrompt component={'span'}>\n <PreviewPrompt defaultClassName=\"prompt\" prompt={model.prompt} />\n </StyledPrompt>\n )}\n\n {annotatorMode ? (\n <AnnotationEditor\n text={value || ''}\n annotations={annotations || []}\n comment={comment || ''}\n predefinedAnnotations={predefinedAnnotations || []}\n onChange={onAnnotationsChange}\n onCommentChange={this.changeSessionComment}\n width={width}\n height={height}\n maxHeight={maxHeight}\n disabled={disabledAnnotator}\n disabledMath={!mathInput}\n customKeys={customKeys}\n keypadMode={equationEditor}\n />\n ) : (\n <Editor\n className=\"response-area-editor\"\n onChange={this.changeSessionValue}\n markup={value || ''}\n maxWidth={width && width.toString()}\n minWidth={'100px'}\n minHeight={height && height.toString()}\n maxHeight={maxHeight}\n disabled={disabled}\n highlightShape={true}\n toolbarOpts={toolbarOpts}\n spellCheck={spellCheckEnabled}\n charactersLimit={50000}\n autoWidthToolbar\n pluginProps={{\n math: {\n disabled: !mathInput,\n customKeys: this.props.model.customKeys,\n keypadMode: this.props.model.equationEditor,\n controlledKeypadMode: false,\n },\n video: {\n disabled: true,\n },\n audio: {\n disabled: true,\n },\n table: {\n disabled: true,\n },\n textAlign: {\n disabled: true,\n },\n separateParagraphs: { disabled: false },\n ul_list: { disabled: true },\n ol_list: { disabled: true },\n }}\n languageCharactersProps={languageCharactersProps}\n />\n )}\n\n {feedback && <Feedback correctness=\"correct\" feedback={feedback} />}\n </MainContainer>\n );\n }\n}\n\nexport default Main;\n"],"mappings":";;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,UAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,WAAA,GAAAL,sBAAA,CAAAC,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,mBAAA,GAAAP,sBAAA,CAAAC,OAAA;AACA,IAAAO,SAAA,GAAAP,OAAA;AAEA,IAAAQ,iBAAA,GAAAT,sBAAA,CAAAC,OAAA;AAEA,MAAMS,GAAG,GAAG,IAAAC,cAAK,EAAC,6BAA6B,CAAC;AAEhD,MAAMC,aAAa,GAAG,IAAAC,cAAM,EAACC,kBAAQ,CAAC,CAAC;EACrCC,eAAe,EAAEC,eAAK,CAACC,UAAU,CAAC,CAAC;EACnCD,KAAK,EAAEA,eAAK,CAACE,IAAI,CAAC;AACpB,CAAC,CAAC;AAEF,MAAMC,YAAY,GAAG,IAAAN,cAAM,EAACO,mBAAU,CAAC,CAAC,CAAC;EAAEC;AAAM,CAAC,MAAM;EACtDC,KAAK,EAAE,MAAM;EACbN,KAAK,EAAEA,eAAK,CAACE,IAAI,CAAC,CAAC;EACnBK,YAAY,EAAEF,KAAK,CAACG,OAAO,CAAC,CAAC,CAAC;EAC9BC,QAAQ,EAAE;AACZ,CAAC,CAAC,CAAC;AAEH,MAAMC,mBAAmB,GAAG,IAAAb,cAAM,EAAC,KAAK,CAAC,CAAC,CAAC;EAAEQ;AAAM,CAAC,MAAM;EACxDE,YAAY,EAAEF,KAAK,CAACG,OAAO,CAAC,CAAC;AAC/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AAS,CAACK,MAAM;IACvBpD,WAAW,EAAE+C,kBAAS,CAACM,KAAK;IAC5BpD,OAAO,EAAE8C,kBAAS,CAACK;EACrB,CAAC,CAAC,CAACH;AACL,CAAC;AAAA,IAAAK,QAAA,GAAAR,OAAA,CAAAxE,OAAA,GA6IYN,IAAI","ignoreList":[]}
package/lib/print.js CHANGED
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.default = void 0;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _client = require("react-dom/client");
10
- var _debounce = _interopRequireDefault(require("lodash/debounce"));
10
+ var _lodashEs = require("lodash-es");
11
11
  var _main = _interopRequireDefault(require("./main"));
12
12
  var _mathRendering = require("@pie-lib/math-rendering");
13
13
  var _debug = _interopRequireDefault(require("debug"));
@@ -38,7 +38,7 @@ class ExtendedTextEntryPrint extends HTMLElement {
38
38
  this._model = null;
39
39
  this._session = [];
40
40
  this._root = null;
41
- this._rerender = (0, _debounce.default)(() => {
41
+ this._rerender = (0, _lodashEs.debounce)(() => {
42
42
  if (this._model && this._session) {
43
43
  const printModel = preparePrintModel(this._model, this._options);
44
44
  const element = this._options && /*#__PURE__*/_react.default.createElement(_main.default, {
package/lib/print.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"print.js","names":["_react","_interopRequireDefault","require","_client","_debounce","_main","_mathRendering","_debug","log","debug","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","mode","defaultDimensions","height","width","dimensions","disabled","feedback","animationsDisabled","ExtendedTextEntryPrint","HTMLElement","constructor","_options","_model","_session","_root","_rerender","debounce","printModel","element","React","createElement","Main","session","onChange","onValueChange","onAnnotationsChange","onCommentChange","createRoot","render","queueMicrotask","renderMath","leading","trailing","options","o","s","connectedCallback","disconnectedCallback","unmount","exports","default"],"sources":["../src/print.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debounce from 'lodash/debounce';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport debug from 'debug';\n\nconst log = debug('pie-element:extended-text-entry:print');\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.showTeacherInstructions = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n const defaultDimensions = { height: 100, width: 500 };\n\n model.dimensions = {\n ...defaultDimensions,\n ...model.dimensions,\n };\n\n model.disabled = true;\n model.feedback = undefined;\n model.animationsDisabled = true;\n\n return model;\n};\n\nexport default class ExtendedTextEntryPrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._root = null;\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n onChange: () => {},\n onValueChange: () => {},\n onAnnotationsChange: () => {},\n onCommentChange: () => {},\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n queueMicrotask(() => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,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OAAA,GAAAhC,sBAAA","ignoreList":[]}
1
+ {"version":3,"file":"print.js","names":["_react","_interopRequireDefault","require","_client","_lodashEs","_main","_mathRendering","_debug","log","debug","preparePrintModel","model","opts","instr","role","prompt","promptEnabled","undefined","teacherInstructions","teacherInstructionsEnabled","showTeacherInstructions","mode","defaultDimensions","height","width","dimensions","disabled","feedback","animationsDisabled","ExtendedTextEntryPrint","HTMLElement","constructor","_options","_model","_session","_root","_rerender","debounce","printModel","element","React","createElement","Main","session","onChange","onValueChange","onAnnotationsChange","onCommentChange","createRoot","render","queueMicrotask","renderMath","leading","trailing","options","o","s","connectedCallback","disconnectedCallback","unmount","exports","default"],"sources":["../src/print.js"],"sourcesContent":["import React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport { debounce } from 'lodash-es';\nimport Main from './main';\nimport { renderMath } from '@pie-lib/math-rendering';\n\nimport debug from 'debug';\n\nconst log = debug('pie-element:extended-text-entry:print');\n\nconst preparePrintModel = (model, opts) => {\n const instr = opts.role === 'instructor';\n\n model.prompt = model.promptEnabled !== false ? model.prompt : undefined;\n model.teacherInstructions =\n instr && model.teacherInstructionsEnabled !== false ? model.teacherInstructions : undefined;\n model.showTeacherInstructions = instr;\n model.mode = instr ? 'evaluate' : model.mode;\n\n const defaultDimensions = { height: 100, width: 500 };\n\n model.dimensions = {\n ...defaultDimensions,\n ...model.dimensions,\n };\n\n model.disabled = true;\n model.feedback = undefined;\n model.animationsDisabled = true;\n\n return model;\n};\n\nexport default class ExtendedTextEntryPrint extends HTMLElement {\n constructor() {\n super();\n this._options = null;\n this._model = null;\n this._session = [];\n this._root = null;\n this._rerender = debounce(\n () => {\n if (this._model && this._session) {\n const printModel = preparePrintModel(this._model, this._options);\n\n const element =\n this._options &&\n React.createElement(Main, {\n model: printModel,\n session: {},\n onChange: () => {},\n onValueChange: () => {},\n onAnnotationsChange: () => {},\n onCommentChange: () => {},\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n queueMicrotask(() => {\n log('render complete - render math');\n renderMath(this);\n });\n } else {\n log('skip');\n }\n },\n 50,\n { leading: false, trailing: true },\n );\n }\n set options(o) {\n this._options = o;\n }\n\n set model(s) {\n this._model = s;\n this._rerender();\n }\n\n connectedCallback() {}\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAN,sBAAA,CAAAC,OAAA;AAEA,MAAMM,GAAG,GAAG,IAAAC,cAAK,EAAC,uCAAuC,CAAC;AAE1D,MAAMC,iBAAiB,GAAGA,CAACC,KAAK,EAAEC,IAAI,KAAK;EACzC,MAAMC,KAAK,GAAGD,IAAI,CAACE,IAAI,KAAK,YAAY;EAExCH,KAAK,CAACI,MAAM,GAAGJ,KAAK,CAACK,aAAa,KAAK,KAAK,GAAGL,KAAK,CAACI,MAAM,GAAGE,SAAS;EACvEN,KAAK,CAACO,mBAAmB,GACvBL,KAAK,IAAIF,KAAK,CAACQ,0BAA0B,KAAK,KAAK,GAAGR,KAAK,CAACO,mBAAmB,GAAGD,SAAS;EAC7FN,KAAK,CAACS,uBAAuB,GAAGP,KAAK;EACrCF,KAAK,CAACU,IAAI,GAAGR,KAAK,GAAG,UAAU,GAAGF,KAAK,CAACU,IAAI;EAE5C,MAAMC,iBAAiB,GAAG;IAAEC,MAAM,EAAE,GAAG;IAAEC,KAAK,EAAE;EAAI,CAAC;EAErDb,KAAK,CAACc,UAAU,GAAG;IACjB,GAAGH,iBAAiB;IACpB,GAAGX,KAAK,CAACc;EACX,CAAC;EAEDd,KAAK,CAACe,QAAQ,GAAG,IAAI;EACrBf,KAAK,CAACgB,QAAQ,GAAGV,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AAE,EACF;MAAE4C,OAAO,EAAE,KAAK;MAAEC,QAAQ,EAAE;IAAK,CACnC,CAAC;EACH;EACA,IAAIC,OAAOA,CAACC,CAAC,EAAE;IACb,IAAI,CAACvB,QAAQ,GAAGuB,CAAC;EACnB;EAEA,IAAI5C,KAAKA,CAAC6C,CAAC,EAAE;IACX,IAAI,CAACvB,MAAM,GAAGuB,CAAC;IACf,IAAI,CAACpB,SAAS,CAAC,CAAC;EAClB;EAEAqB,iBAAiBA,CAAA,EAAG,CAAC;EAErBC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACvB,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACwB,OAAO,CAAC,CAAC;IACtB;EACF;AACF;AAACC,OAAA,CAAAC,OAAA,GAAAhC,sBAAA","ignoreList":[]}
@@ -1 +1 @@
1
- import{_dll_react_dom as e,_dll_react as t,_dll_prop_types as n,_dll_mui__material as i,_dll_mui__material_styles as a}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";import{_dll_pie_lib__config_ui as s}from"../../../@pie-lib/config-module@^3.0.0/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as o}from"../../../@pie-lib/editable-html-module@^6.0.5/module/index.js";var l={};Object.defineProperty(l,"__esModule",{value:!0});class r extends CustomEvent{constructor(e,t=!1){super(r.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}r.TYPE="model.updated";var d=l.ModelUpdatedEvent=r;class c extends CustomEvent{constructor(e,t){super(c.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}c.TYPE="delete.image";var p=l.DeleteImageEvent=c;class u extends CustomEvent{constructor(e){super(u.TYPE,{bubbles:!0,detail:e}),this.handler=e}}u.TYPE="insert.image";var h=l.InsertImageEvent=u;class g extends CustomEvent{constructor(e,t){super(g.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}g.TYPE="delete.sound";var b=l.DeleteSoundEvent=g;class m extends CustomEvent{constructor(e){super(m.TYPE,{bubbles:!0,detail:e}),this.handler=e}}m.TYPE="insert.sound";var _,E=l.InsertSoundEvent=m,f=e;_=f.createRoot,f.hydrateRoot;const C=t,I=n,{Typography:v}=i,{styled:S}=a,{FeedbackSelector:x}=s,{InputContainer:y}=s,{settings:k}=s,{layout:P}=s,w=o,{ALL_PLUGINS:M}=o;function T(e){let t,n=e[0],i=1;for(;i<e.length;){const a=e[i],s=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==n)return;"access"===a||"optionalAccess"===a?(t=n,n=s(n)):"call"!==a&&"optionalCall"!==a||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}const{Panel:A,toggle:D,numberFields:R,dropdown:q}=k,Y={type:"default",default:"Your answer has been submitted"},O=S(v)(({theme:e})=>({paddingBottom:e.spacing(1)})),j=S(y)(({theme:e})=>({paddingTop:e.spacing(1),marginTop:e.spacing(2),marginBottom:e.spacing(2),width:"100%"})),H=S("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)}));class F extends C.Component{static __initStatic(){this.propTypes={onModelChanged:I.func.isRequired,onConfigurationChanged:I.func,model:I.object.isRequired,configuration:I.object.isRequired,imageSupport:I.object.isRequired,uploadSoundSupport:I.object.isRequired}}constructor(e){super(e),F.prototype.__init.call(this),F.prototype.__init2.call(this),F.prototype.__init3.call(this),this.state={setDimensions:!0}}__init(){this.onPromptChange=e=>{const{onModelChanged:t,model:n}=this.props;t({...n,prompt:e})}}__init2(){this.changeFeedback=e=>{const{model:t,onModelChanged:n}=this.props;n({...t,feedback:e})}}__init3(){this.changeTeacherInstructions=e=>{const{model:t,onModelChanged:n}=this.props;n({...t,teacherInstructions:e})}}render(){const{model:e,configuration:t,imageSupport:n,onConfigurationChanged:i,onModelChanged:a,uploadSoundSupport:s}=this.props,{annotations:o={},contentDimensions:l={},dimensions:r={},equationEditor:d={},feedback:c={},playerSpellCheck:p={},prompt:u={},settingsPanelDisabled:h,spanishInput:g={},specialInput:b={},spellCheck:m={},studentInstructions:_={},teacherInstructions:E={},mathInput:f={},maxImageWidth:I={},maxImageHeight:v={},multiple:S={},withRubric:y={},mathMlOptions:k={},baseInputConfiguration:F={}}=t||{},{errors:G={},extraCSSRules:W,feedbackEnabled:L,promptEnabled:z,spellCheckEnabled:N,teacherInstructionsEnabled:B,toolbarEditorPosition:U}=e||{},{prompt:J,teacherInstructions:K}=G,Q=I&&I.prompt,V=v&&v.prompt,X={position:"top"===U?"top":"bottom"},Z={mathInput:f.settings&&D(f.label),equationEditor:d.enabled&&e.mathInput&&q(d.label,["non-negative-integers","integers","decimals","fractions","Grade 1 - 2","Grade 3 - 5","Grade 6 - 7","Grade 8 - HS","geometry","advanced-algebra","statistics","item-authoring"]),spanishInput:g.settings&&D(g.label),specialInput:b.settings&&D(b.label),dimensions:r.settings&&R(r.label,{width:{label:"Width (px)",suffix:"px",min:100,max:1200},height:{label:"Height (px)",suffix:"px",min:100,max:500}}),"multiple.enabled":S.settings&&D(S.label,!0),promptEnabled:u.settings&&D(u.label),feedbackEnabled:c.settings&&D(c.label),annotationsEnabled:o.settings&&D(o.label),spellCheckEnabled:m.settings&&D(m.label),playerSpellCheckDisabled:p.settings&&D(p.label)},$={teacherInstructionsEnabled:E.settings&&D(E.label),studentInstructionsEnabled:_.settings&&D(_.label),rubricEnabled:T([y,"optionalAccess",e=>e.settings])&&D(T([y,"optionalAccess",e=>e.label]))},ee=e=>Object.assign({...F},e||{});return C.createElement(P.ConfigLayout,{extraCSSRules:W,dimensions:l,hideSettings:h,settings:C.createElement(A,{model:e,configuration:t,onChangeModel:e=>a(e),onChangeConfiguration:e=>i(e),groups:{Settings:Z,Properties:$}})},B&&C.createElement(j,{label:E.label},C.createElement(w,{className:"prompt",markup:e.teacherInstructions||"",onChange:this.changeTeacherInstructions,imageSupport:n,nonEmpty:!1,error:K,toolbarOpts:X,spellCheck:N,maxImageWidth:I&&I.teacherInstructions||Q,maxImageHeight:v&&v.teacherInstructions||V,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:k,pluginProps:ee(T([E,"optionalAccess",e=>e.inputConfiguration]))}),K&&C.createElement(H,null,K)),z&&C.createElement(j,{label:u.label},C.createElement(w,{activePlugins:M,className:"prompt",markup:e.prompt||"",onChange:this.onPromptChange,imageSupport:n,nonEmpty:!1,error:J,toolbarOpts:X,spellCheck:N,maxImageWidth:Q,maxImageHeight:V,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:k,pluginProps:ee(T([u,"optionalAccess",e=>e.inputConfiguration]))}),J&&C.createElement(H,null,J)),L&&C.createElement(C.Fragment,null,C.createElement(O,{variant:"h6"},"Feedback"),C.createElement(x,{label:"When submitted, show",feedback:e.feedback||Y,onChange:this.changeFeedback,toolbarOpts:X})))}}F.__initStatic();var G={annotationsEnabled:!1,dimensions:{height:100,width:500},equationEditor:"Grade 8 - HS",feedbackEnabled:!1,mathInput:!1,playerSpellCheckDisabled:!0,predefinedAnnotations:[{label:"good",text:"good",type:"positive"},{label:"★",text:"★",type:"positive"},{label:":-)",text:":-)",type:"positive"},{label:"creative",text:"creative",type:"positive"},{label:"run-on",text:"run-on",type:"negative"},{label:"frag",text:"fragment",type:"negative"},{label:"tran",text:"transition",type:"negative"},{label:"supp",text:"support needed",type:"negative"},{label:"punc",text:"punctuation",type:"negative"},{label:"agr",text:"agreement wrong",type:"negative"},{label:"unclear",text:"unclear",type:"negative"},{label:"cut",text:"cut",type:"negative"},{label:"sp",text:"spelling",type:"negative"},{label:"cap",text:"capitalization",type:"negative"},{label:"inf",text:"informal",type:"negative"},{label:"awk",text:"awkward",type:"negative"}],prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,spanishInput:!1,specialInput:!1,spellCheckEnabled:!0,studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom"},W={annotations:{settings:!1,label:"Annotations"},baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!0},blockquote:{disabled:!0},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},dimensions:{settings:!0,label:"Text-Entry Display Size"},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},playerSpellCheck:{label:"Disable Student Spellcheck",settings:!0,enabled:!0},equationEditor:{settings:!1,label:"Equation Editor",enabled:!0},feedback:{settings:!0,label:"Feedback"},mathInput:{settings:!0,label:"Student response can include math notation",enabled:!1},settingsPanelDisabled:!1,spanishInput:{settings:!0,label:"Students can insert Spanish",enabled:!1},specialInput:{settings:!0,label:"Students can insert Special Characters",enabled:!1},multiple:{settings:!1,label:"Multiple Parts",enabled:!1},studentInstructions:{settings:!1,label:"Student Instructions"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},maxImageWidth:{teacherInstructions:300,prompt:300},maxImageHeight:{teacherInstructions:300,prompt:300},withRubric:{settings:!1,label:"Add Rubric"},mathMlOptions:{mmlOutput:!1,mmlEditing:!1}};const L=t;function z(e){let t,n=e[0],i=1;for(;i<e.length;){const a=e[i],s=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==n)return;"access"===a||"optionalAccess"===a?(t=n,n=s(n)):"call"!==a&&"optionalCall"!==a||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}class N extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={},t)=>{const n={...G,...e};return z([t,"optionalAccess",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&!n.rubricEnabled&&(n.rubricEnabled=!0),n}}constructor(){super(),this._root=null,this._configuration=W,z([this,"access",e=>e._configuration,"access",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1),this._model=N.createDefaultModel({},this._configuration)}set model(e){this._model=N.createDefaultModel(e,this._configuration),this.render()}set configuration(e){this._configuration={...W,...e};const{withRubric:t={}}=e||{};z([t,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1,this._model.rubricEnabled||(this._model.rubricEnabled=!0)),this.render()}onModelChanged(e){this._model=e,this.render(),this.dispatchEvent(new d(this._model,!1))}onConfigurationChanged(e){this._configuration={...W,...e},this._model&&this.onModelChanged(this._model),this.render()}insertImage(e){this.dispatchEvent(new h(e))}onDeleteImage(e,t){this.dispatchEvent(new p(e,t))}insertSound(e){this.dispatchEvent(new E(e))}onDeleteSound(e,t){this.dispatchEvent(new b(e,t))}render(){if(this._model){const e=L.createElement(F,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged.bind(this),onConfigurationChanged:this.onConfigurationChanged.bind(this),imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(this._root=_(this)),this._root.render(e)}}disconnectedCallback(){this._root&&this._root.unmount()}}N.__initStatic();export{N as default};
1
+ import{_dll_react_dom as e,_dll_react as t,_dll_prop_types as n,_dll_mui__material as i,_dll_mui__material_styles as a}from"../../../@pie-lib/shared-module@^4.0.1/module/index.js";import{_dll_pie_lib__config_ui as s}from"../../../@pie-lib/config-module@^3.0.1/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as o}from"../../../@pie-lib/editable-html-module@^6.1.2/module/index.js";var l={};Object.defineProperty(l,"__esModule",{value:!0});class r extends CustomEvent{constructor(e,t=!1){super(r.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}r.TYPE="model.updated";var d=l.ModelUpdatedEvent=r;class c extends CustomEvent{constructor(e,t){super(c.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}c.TYPE="delete.image";var p=l.DeleteImageEvent=c;class u extends CustomEvent{constructor(e){super(u.TYPE,{bubbles:!0,detail:e}),this.handler=e}}u.TYPE="insert.image";var h=l.InsertImageEvent=u;class g extends CustomEvent{constructor(e,t){super(g.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}g.TYPE="delete.sound";var b=l.DeleteSoundEvent=g;class m extends CustomEvent{constructor(e){super(m.TYPE,{bubbles:!0,detail:e}),this.handler=e}}m.TYPE="insert.sound";var _,E=l.InsertSoundEvent=m,f=e;_=f.createRoot,f.hydrateRoot;const C=t,I=n,{Typography:v}=i,{styled:S}=a,{FeedbackSelector:x}=s,{InputContainer:y}=s,{settings:k}=s,{layout:P}=s,w=o,{ALL_PLUGINS:M}=o;function T(e){let t,n=e[0],i=1;for(;i<e.length;){const a=e[i],s=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==n)return;"access"===a||"optionalAccess"===a?(t=n,n=s(n)):"call"!==a&&"optionalCall"!==a||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}const{Panel:A,toggle:D,numberFields:R,dropdown:q}=k,Y={type:"default",default:"Your answer has been submitted"},O=S(v)(({theme:e})=>({paddingBottom:e.spacing(1)})),j=S(y)(({theme:e})=>({paddingTop:e.spacing(1),marginTop:e.spacing(2),marginBottom:e.spacing(2),width:"100%"})),H=S("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)}));class F extends C.Component{static __initStatic(){this.propTypes={onModelChanged:I.func.isRequired,onConfigurationChanged:I.func,model:I.object.isRequired,configuration:I.object.isRequired,imageSupport:I.object.isRequired,uploadSoundSupport:I.object.isRequired}}constructor(e){super(e),F.prototype.__init.call(this),F.prototype.__init2.call(this),F.prototype.__init3.call(this),this.state={setDimensions:!0}}__init(){this.onPromptChange=e=>{const{onModelChanged:t,model:n}=this.props;t({...n,prompt:e})}}__init2(){this.changeFeedback=e=>{const{model:t,onModelChanged:n}=this.props;n({...t,feedback:e})}}__init3(){this.changeTeacherInstructions=e=>{const{model:t,onModelChanged:n}=this.props;n({...t,teacherInstructions:e})}}render(){const{model:e,configuration:t,imageSupport:n,onConfigurationChanged:i,onModelChanged:a,uploadSoundSupport:s}=this.props,{annotations:o={},contentDimensions:l={},dimensions:r={},equationEditor:d={},feedback:c={},playerSpellCheck:p={},prompt:u={},settingsPanelDisabled:h,spanishInput:g={},specialInput:b={},spellCheck:m={},studentInstructions:_={},teacherInstructions:E={},mathInput:f={},maxImageWidth:I={},maxImageHeight:v={},multiple:S={},withRubric:y={},mathMlOptions:k={},baseInputConfiguration:F={}}=t||{},{errors:G={},extraCSSRules:W,feedbackEnabled:L,promptEnabled:z,spellCheckEnabled:N,teacherInstructionsEnabled:B,toolbarEditorPosition:U}=e||{},{prompt:J,teacherInstructions:K}=G,Q=I&&I.prompt,V=v&&v.prompt,X={position:"top"===U?"top":"bottom"},Z={mathInput:f.settings&&D(f.label),equationEditor:d.enabled&&e.mathInput&&q(d.label,["non-negative-integers","integers","decimals","fractions","Grade 1 - 2","Grade 3 - 5","Grade 6 - 7","Grade 8 - HS","geometry","advanced-algebra","statistics","item-authoring"]),spanishInput:g.settings&&D(g.label),specialInput:b.settings&&D(b.label),dimensions:r.settings&&R(r.label,{width:{label:"Width (px)",suffix:"px",min:100,max:1200},height:{label:"Height (px)",suffix:"px",min:100,max:500}}),"multiple.enabled":S.settings&&D(S.label,!0),promptEnabled:u.settings&&D(u.label),feedbackEnabled:c.settings&&D(c.label),annotationsEnabled:o.settings&&D(o.label),spellCheckEnabled:m.settings&&D(m.label),playerSpellCheckDisabled:p.settings&&D(p.label)},$={teacherInstructionsEnabled:E.settings&&D(E.label),studentInstructionsEnabled:_.settings&&D(_.label),rubricEnabled:T([y,"optionalAccess",e=>e.settings])&&D(T([y,"optionalAccess",e=>e.label]))},ee=e=>Object.assign({...F},e||{});return C.createElement(P.ConfigLayout,{extraCSSRules:W,dimensions:l,hideSettings:h,settings:C.createElement(A,{model:e,configuration:t,onChangeModel:e=>a(e),onChangeConfiguration:e=>i(e),groups:{Settings:Z,Properties:$}})},B&&C.createElement(j,{label:E.label},C.createElement(w,{className:"prompt",markup:e.teacherInstructions||"",onChange:this.changeTeacherInstructions,imageSupport:n,nonEmpty:!1,error:K,toolbarOpts:X,spellCheck:N,maxImageWidth:I&&I.teacherInstructions||Q,maxImageHeight:v&&v.teacherInstructions||V,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:k,pluginProps:ee(T([E,"optionalAccess",e=>e.inputConfiguration]))}),K&&C.createElement(H,null,K)),z&&C.createElement(j,{label:u.label},C.createElement(w,{activePlugins:M,className:"prompt",markup:e.prompt||"",onChange:this.onPromptChange,imageSupport:n,nonEmpty:!1,error:J,toolbarOpts:X,spellCheck:N,maxImageWidth:Q,maxImageHeight:V,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:k,pluginProps:ee(T([u,"optionalAccess",e=>e.inputConfiguration]))}),J&&C.createElement(H,null,J)),L&&C.createElement(C.Fragment,null,C.createElement(O,{variant:"h6"},"Feedback"),C.createElement(x,{label:"When submitted, show",feedback:e.feedback||Y,onChange:this.changeFeedback,toolbarOpts:X})))}}F.__initStatic();var G={annotationsEnabled:!1,dimensions:{height:100,width:500},equationEditor:"Grade 8 - HS",feedbackEnabled:!1,mathInput:!1,playerSpellCheckDisabled:!0,predefinedAnnotations:[{label:"good",text:"good",type:"positive"},{label:"★",text:"★",type:"positive"},{label:":-)",text:":-)",type:"positive"},{label:"creative",text:"creative",type:"positive"},{label:"run-on",text:"run-on",type:"negative"},{label:"frag",text:"fragment",type:"negative"},{label:"tran",text:"transition",type:"negative"},{label:"supp",text:"support needed",type:"negative"},{label:"punc",text:"punctuation",type:"negative"},{label:"agr",text:"agreement wrong",type:"negative"},{label:"unclear",text:"unclear",type:"negative"},{label:"cut",text:"cut",type:"negative"},{label:"sp",text:"spelling",type:"negative"},{label:"cap",text:"capitalization",type:"negative"},{label:"inf",text:"informal",type:"negative"},{label:"awk",text:"awkward",type:"negative"}],prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,spanishInput:!1,specialInput:!1,spellCheckEnabled:!0,studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom"},W={annotations:{settings:!1,label:"Annotations"},baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!0},blockquote:{disabled:!0},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},dimensions:{settings:!0,label:"Text-Entry Display Size"},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},playerSpellCheck:{label:"Disable Student Spellcheck",settings:!0,enabled:!0},equationEditor:{settings:!1,label:"Equation Editor",enabled:!0},feedback:{settings:!0,label:"Feedback"},mathInput:{settings:!0,label:"Student response can include math notation",enabled:!1},settingsPanelDisabled:!1,spanishInput:{settings:!0,label:"Students can insert Spanish",enabled:!1},specialInput:{settings:!0,label:"Students can insert Special Characters",enabled:!1},multiple:{settings:!1,label:"Multiple Parts",enabled:!1},studentInstructions:{settings:!1,label:"Student Instructions"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},maxImageWidth:{teacherInstructions:300,prompt:300},maxImageHeight:{teacherInstructions:300,prompt:300},withRubric:{settings:!1,label:"Add Rubric"},mathMlOptions:{mmlOutput:!1,mmlEditing:!1}};const L=t;function z(e){let t,n=e[0],i=1;for(;i<e.length;){const a=e[i],s=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==n)return;"access"===a||"optionalAccess"===a?(t=n,n=s(n)):"call"!==a&&"optionalCall"!==a||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}class N extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={},t)=>{const n={...G,...e};return z([t,"optionalAccess",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&!n.rubricEnabled&&(n.rubricEnabled=!0),n}}constructor(){super(),this._root=null,this._configuration=W,z([this,"access",e=>e._configuration,"access",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1),this._model=N.createDefaultModel({},this._configuration)}set model(e){this._model=N.createDefaultModel(e,this._configuration),this.render()}set configuration(e){this._configuration={...W,...e};const{withRubric:t={}}=e||{};z([t,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1,this._model.rubricEnabled||(this._model.rubricEnabled=!0)),this.render()}onModelChanged(e){this._model=e,this.render(),this.dispatchEvent(new d(this._model,!1))}onConfigurationChanged(e){this._configuration={...W,...e},this._model&&this.onModelChanged(this._model),this.render()}insertImage(e){this.dispatchEvent(new h(e))}onDeleteImage(e,t){this.dispatchEvent(new p(e,t))}insertSound(e){this.dispatchEvent(new E(e))}onDeleteSound(e,t){this.dispatchEvent(new b(e,t))}render(){if(this._model){const e=L.createElement(F,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged.bind(this),onConfigurationChanged:this.onConfigurationChanged.bind(this),imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(this._root=_(this)),this._root.render(e)}}disconnectedCallback(){this._root&&this._root.unmount()}}N.__initStatic();export{N as default};
package/module/element.js CHANGED
@@ -1 +1 @@
1
- import{_dll_prop_types as e,_dll_mui__material as t,_dll_mui__material_styles as n,_dll_lodash as o,_dll_debug as r,_dll_pie_lib__render_ui as i,_dll_react_dom as s}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";import{_dll_pie_lib__math_rendering as a}from"../../../@pie-lib/math-rendering-module@^4.0.5/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^6.0.5/module/index.js";import{_dll_pie_lib__config_ui as c}from"../../../@pie-lib/config-module@^3.0.0/module/index.js";var d={exports:{}},p={},u=Symbol.for("react.element"),h=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),b=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),_=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),E=Symbol.iterator;var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,k={};function R(e,t,n){this.props=e,this.context=t,this.refs=k,this.updater=n||S}function A(){}function T(e,t,n){this.props=e,this.context=t,this.refs=k,this.updater=n||S}R.prototype.isReactComponent={},R.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},R.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},A.prototype=R.prototype;var P=T.prototype=new A;P.constructor=T,w(P,R.prototype),P.isPureReactComponent=!0;var L=Array.isArray,M=Object.prototype.hasOwnProperty,I={current:null},$={key:!0,ref:!0,__self:!0,__source:!0};function N(e,t,n){var o,r={},i=null,s=null;if(null!=t)for(o in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(i=""+t.key),t)M.call(t,o)&&!$.hasOwnProperty(o)&&(r[o]=t[o]);var a=arguments.length-2;if(1===a)r.children=n;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];r.children=l}if(e&&e.defaultProps)for(o in a=e.defaultProps)void 0===r[o]&&(r[o]=a[o]);return{$$typeof:u,type:e,key:i,ref:s,props:r,_owner:I.current}}function D(e){return"object"==typeof e&&null!==e&&e.$$typeof===u}var O=/\/+/g;function j(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function H(e,t,n,o,r){var i=typeof e;"undefined"!==i&&"boolean"!==i||(e=null);var s=!1;if(null===e)s=!0;else switch(i){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case u:case h:s=!0}}if(s)return r=r(s=e),e=""===o?"."+j(s,0):o,L(r)?(n="",null!=e&&(n=e.replace(O,"$&/")+"/"),H(r,t,n,"",function(e){return e})):null!=r&&(D(r)&&(r=function(e,t){return{$$typeof:u,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(r,n+(!r.key||s&&s.key===r.key?"":(""+r.key).replace(O,"$&/")+"/")+e)),t.push(r)),1;if(s=0,o=""===o?".":o+":",L(e))for(var a=0;a<e.length;a++){var l=o+j(i=e[a],a);s+=H(i,t,n,l,r)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=E&&e[E]||e["@@iterator"])?e:null}(e),"function"==typeof l)for(e=l.call(e),a=0;!(i=e.next()).done;)s+=H(i=i.value,t,n,l=o+j(i,a++),r);else if("object"===i)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return s}function W(e,t,n){if(null==e)return e;var o=[],r=0;return H(e,o,"","",function(e){return t.call(n,e,r++)}),o}function z(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var q={current:null},V={transition:null},U={ReactCurrentDispatcher:q,ReactCurrentBatchConfig:V,ReactCurrentOwner:I};function F(){throw Error("act(...) is not supported in production builds of React.")}p.Children={map:W,forEach:function(e,t,n){W(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return W(e,function(){t++}),t},toArray:function(e){return W(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},p.Component=R,p.Fragment=f,p.Profiler=g,p.PureComponent=T,p.StrictMode=m,p.Suspense=C,p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=U,p.act=F,p.cloneElement=function(e,t,n){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var o=w({},e.props),r=e.key,i=e.ref,s=e._owner;if(null!=t){if(void 0!==t.ref&&(i=t.ref,s=I.current),void 0!==t.key&&(r=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in t)M.call(t,l)&&!$.hasOwnProperty(l)&&(o[l]=void 0===t[l]&&void 0!==a?a[l]:t[l])}var l=arguments.length-2;if(1===l)o.children=n;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];o.children=a}return{$$typeof:u,type:e.type,key:r,ref:i,props:o,_owner:s}},p.createContext=function(e){return(e={$$typeof:b,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:y,_context:e},e.Consumer=e},p.createElement=N,p.createFactory=function(e){var t=N.bind(null,e);return t.type=e,t},p.createRef=function(){return{current:null}},p.forwardRef=function(e){return{$$typeof:v,render:e}},p.isValidElement=D,p.lazy=function(e){return{$$typeof:x,_payload:{_status:-1,_result:e},_init:z}},p.memo=function(e,t){return{$$typeof:_,type:e,compare:void 0===t?null:t}},p.startTransition=function(e){var t=V.transition;V.transition={};try{e()}finally{V.transition=t}},p.unstable_act=F,p.useCallback=function(e,t){return q.current.useCallback(e,t)},p.useContext=function(e){return q.current.useContext(e)},p.useDebugValue=function(){},p.useDeferredValue=function(e){return q.current.useDeferredValue(e)},p.useEffect=function(e,t){return q.current.useEffect(e,t)},p.useId=function(){return q.current.useId()},p.useImperativeHandle=function(e,t,n){return q.current.useImperativeHandle(e,t,n)},p.useInsertionEffect=function(e,t){return q.current.useInsertionEffect(e,t)},p.useLayoutEffect=function(e,t){return q.current.useLayoutEffect(e,t)},p.useMemo=function(e,t){return q.current.useMemo(e,t)},p.useReducer=function(e,t,n){return q.current.useReducer(e,t,n)},p.useRef=function(e){return q.current.useRef(e)},p.useState=function(e){return q.current.useState(e)},p.useSyncExternalStore=function(e,t,n){return q.current.useSyncExternalStore(e,t,n)},p.useTransition=function(){return q.current.useTransition()},p.version="18.3.1",d.exports=p;var B=d.exports;const K=(e,t,n)=>{const o=n||[],r=o.reduce((e,t)=>e+t.textContent.length,0);let i=!0;if(r>t)return!1;for(e&&(3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&o.push(e),e=e.firstChild);e&&i;)i=K(e,t,o),e=e.nextSibling;return o},Y=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o,startOffset:r,endOffset:i}=e,s=[];let a=!1,l=!1,c="";const d=e=>{const{nodeValue:t,childNodes:p}=e;e===n&&e===o?(t&&(c+=t.substring(r,i)),a=l=!0):e===n?(t&&(c+=t.substring(r)),a=!0):e===o?(t&&(c+=t.substring(0,i)),l=!0):e&&3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&t&&a&&!l&&(c+=t,s.push(e)),p.forEach(e=>{l||d(e)})};return d(t),[s,c]},G=e=>{const t=document.createElement("SPAN");return e.surroundContents(t),t},X=e=>{if(e.startContainer===e.endContainer)return[G(e)];const[t]=Y(e),n=document.createRange();n.selectNodeContents(e.startContainer),n.setStart(e.startContainer,e.startOffset);const o=G(n),r=document.createRange();r.selectNode(e.endContainer),r.setEnd(e.endContainer,e.endOffset);const i=G(r);return[o,...t.map(e=>{const t=document.createElement("SPAN");return e.parentNode.insertBefore(t,e),t.appendChild(e),t}),i]},Q=(e,t)=>{(e||[]).forEach(e=>{const t=e.parentNode,n=e.childNodes,o=n.length;if(o>0)for(let r=0;r<o;r++)t.insertBefore(n[0],e);else t.insertBefore(document.createTextNode(e.textContent),e);t.removeChild(e)}),t.normalize()},J=()=>{document.getSelection?(document.getSelection().removeAllRanges(),document.getSelection().addRange(document.createRange())):window.getSelection?window.getSelection().removeAllRanges?(window.getSelection().removeAllRanges(),window.getSelection().addRange(document.createRange())):window.getSelection().empty&&window.getSelection().empty():document.selection&&document.selection.empty()},Z=e=>e.length>=20||-1!==e.search(/\n|\r|\r\n/),ee=e=>Array.from(document.querySelectorAll(`[data-id='${e}']`)),te=e=>document.querySelector(`[data-ann-id='${e}']`),ne=e,{Popover:oe}=t,{TextField:re}=t,{styled:ie}=n,se=ie(oe)(({theme:e,annotationType:t})=>({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginLeft:"16px","&::before":{position:"absolute",right:"100%",top:"13px",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderRightColor:e.palette.grey[100]},..."negative"===t&&{"&::before":{borderRightColor:"rgb(255, 204, 238) !important"}},..."positive"===t&&{"&::before":{borderRightColor:"rgb(153, 255, 153) !important"}}}})),ae=ie("div")(({theme:e,annotationType:t})=>({width:"200px",overflow:"hidden",borderRadius:"4px",backgroundColor:"#ffffff",border:`4px solid ${e.palette.grey[100]}`,..."negative"===t&&{borderColor:"rgb(255, 204, 238) !important"},..."positive"===t&&{borderColor:"rgb(153, 255, 153) !important"}})),le=ie("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),ce=ie("div")(({theme:e,variant:t,annotationType:n})=>({flexGrow:1,width:"28%",textAlign:"center",padding:"4px",cursor:"pointer","&:not(:nth-child(3n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}},..."typeChange"===t&&"negative"===n&&{"&:hover":{backgroundColor:"rgb(153, 255, 153) !important"}},..."typeChange"===t&&"positive"===n&&{"&:hover":{backgroundColor:"rgb(255, 204, 238) !important"}}}));class de extends B.Component{static __initStatic(){this.propTypes={anchorEl:ne.object,open:ne.bool,offset:ne.number,value:ne.string,type:ne.string,onClose:ne.func,onDelete:ne.func,onSave:ne.func,onTypeChange:ne.func}}constructor(e){super(e),de.prototype.__init.call(this),de.prototype.__init2.call(this),de.prototype.__init3.call(this),this.state={value:e.value}}UNSAFE_componentWillReceiveProps(e){const{value:t}=e,{value:n}=this.props;t!==n&&this.setState({value:t})}__init(){this.onValueChange=e=>this.setState({value:e.target.value})}__init2(){this.handleSave=()=>{const{value:e,onSave:t,onClose:n,onDelete:o}=this.props,{value:r}=this.state;""===r&&o(),e!==r&&t(e,r),this.setState({value:""}),n()}}__init3(){this.handleTypeChange=()=>{const{onTypeChange:e,onDelete:t}=this.props,{value:n}=this.state;""===n?t():e(n),this.setState({value:""})}}render(){const{anchorEl:e,offset:t,onDelete:n,open:o,type:r}=this.props,{value:i}=this.state;return B.createElement(se,{anchorEl:e,elevation:2,open:o,onClose:this.handleSave,annotationType:r,style:{marginTop:`${t}px`,transition:"margin-top 2s ease-out"},transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"}},B.createElement(ae,{annotationType:r},B.createElement(re,{id:"annotation-editor",style:{padding:"2px 5px",width:"95%"},autoFocus:!0,multiline:!0,rows:1,maxRows:4,value:i,onChange:this.onValueChange,InputProps:{disableUnderline:!0}}),B.createElement(le,null,B.createElement(ce,{onClick:n},"Delete"),B.createElement(ce,{variant:"typeChange",annotationType:r,onClick:this.handleTypeChange},"negative"===r?"Green":"Pink"),B.createElement(ce,{onClick:this.handleSave},"Save"))))}}de.__initStatic();const pe=e,{styled:ue}=n,{Popover:he}=t,fe=ue(he)({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginTop:"-16px","&::after":{position:"absolute",left:"calc(50% - 7px)",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderTopColor:"black"}}}),me=ue("div")(({theme:e})=>({width:"300px",overflow:"hidden",borderRadius:"4px",backgroundColor:e.palette.common.white,border:`2px solid ${e.palette.grey[100]}`})),ge=ue("div")({display:"flex",flexWrap:"wrap"}),ye=ue("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),be=ue("div")(({theme:e,variant:t})=>({width:"22%",textAlign:"center",padding:"4px",cursor:"pointer",borderBottom:`1px solid ${e.palette.grey[100]}`,"&:not(:nth-child(4n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:nth-child(4n)":{flexGrow:1},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}}}));class ve extends B.Component{static __initStatic(){this.propTypes={anchorEl:pe.object,open:pe.bool,annotations:pe.array,isNewAnnotation:pe.bool,onClose:pe.func,onDelete:pe.func,onEdit:pe.func,onWrite:pe.func,onAnnotate:pe.func}}render(){const{anchorEl:e,annotations:t,isNewAnnotation:n,onAnnotate:o,onClose:r,onEdit:i,onDelete:s,onWrite:a,open:l}=this.props;return B.createElement(fe,{anchorEl:e,open:l,onClose:r,elevation:5,transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}},B.createElement(me,null,B.createElement(ge,null,t.map((e,t)=>B.createElement(be,{key:`annotation-${t}`,variant:e.type,onClick:()=>o(e)},e.label))),B.createElement(ye,null,B.createElement(be,{onClick:r},"Cancel"),B.createElement(be,{style:{pointerEvents:"none"}}),n?B.createElement(B.Fragment,null,B.createElement(be,{variant:"positive",onClick:()=>a("positive")},"Write"),B.createElement(be,{variant:"negative",onClick:()=>a("negative")},"Write")):B.createElement(B.Fragment,null,B.createElement(be,{onClick:s},"Delete"),B.createElement(be,{onClick:i},"Edit")))))}}ve.__initStatic();const{styled:Ce}=n,_e=e,xe=l,{InputContainer:Ee}=c,Se=Ce("div")({padding:"10px 120px 10px 16px",backgroundColor:"rgba(0, 0, 0, 0.06)",border:"1px solid #ccc",borderRadius:"4px",overflowY:"scroll",lineHeight:"36px",whiteSpace:"pre-wrap",overflowWrap:"break-word","& p":{margin:0},"& span[data-latex]":{userSelect:"none","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none"}}),we=Ce("div")({width:"230px"}),ke=Ce("div")({position:"relative",overflowX:"hidden",display:"flex"}),Re=Ce(Ee)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2),marginTop:e.spacing(2),width:"100%"}));if(!document.getElementById("annotation-editor-styles")){const e=document.createElement("style");e.id="annotation-editor-styles",e.textContent='\n .sideAnnotation:before {\n position: absolute;\n right: var(--before-right, 100%);\n top: var(--before-top, 5px);\n border: solid transparent;\n content: "";\n height: 0;\n width: 0;\n pointer-events: none;\n border-width: var(--before-border-width, 7px);\n border-right-color: var(--before-border-color, rgb(153, 255, 153));\n }\n',document.head.appendChild(e)}class Ae extends B.Component{static __initStatic(){this.propTypes={text:_e.string,comment:_e.string,annotations:_e.array,predefinedAnnotations:_e.array,onChange:_e.func.isRequired,onCommentChange:_e.func.isRequired,width:_e.number,height:_e.number,maxHeight:_e.string,disabled:_e.bool,disabledMath:_e.bool,customKeys:_e.array,keypadMode:_e.string}}constructor(e){super(e),Ae.prototype.__init.call(this),Ae.prototype.__init2.call(this),Ae.prototype.__init3.call(this),Ae.prototype.__init4.call(this),Ae.prototype.__init5.call(this),Ae.prototype.__init6.call(this),Ae.prototype.__init7.call(this),Ae.prototype.__init8.call(this),Ae.prototype.__init9.call(this),Ae.prototype.__init10.call(this),Ae.prototype.__init11.call(this),Ae.prototype.__init12.call(this),Ae.prototype.__init13.call(this),Ae.prototype.__init14.call(this),Ae.prototype.__init15.call(this),this.state={anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotation:null,annotationIndex:null}}componentDidMount(){const{annotations:e,text:t}=this.props;t&&e.forEach(e=>{const[t,n]=((e,t,n)=>{const o=K(n,t),r=[];let i=0;return o.forEach(n=>{const o=i+n.textContent.length;[e,t].forEach(e=>{i<=e&&e<o&&r.push({node:n,offset:e-i})}),i=o}),r})(e.start,e.end,this.textRef);if(t&&n){const o=document.createRange();o.setStart(t.node,t.offset),o.setEnd(n.node,n.offset);const r=X(o);this.createDOMAnnotation(r,e)}}),this.textRef&&(this.adjustAnnotationsPosition(),this.textRef.addEventListener("scroll",this.adjustAnnotationsPosition))}__init(){this.adjustAnnotationsPosition=()=>{if(this.textRef&&this.labelsRef){const e=this.textRef.offsetLeft+this.textRef.offsetWidth+8;Array.from(this.labelsRef.children).forEach(t=>{const n=ee(t.dataset.annId),o=(n[0].offsetTop?n[0].offsetTop:n[0].offsetParent.offsetTop)-this.textRef.scrollTop-6;t.style.top=`${o}px`,t.style.left=`${e}px`})}}}__init2(){this.handleClick=e=>{const{annotations:t}=this.props,{selectionDetails:n}=this.state;if(n)return;const{id:o,annId:r}=e.target.dataset,i=o||r,s=ee(i),a=te(i),l=t.findIndex(e=>e.id===i),c=a.hasAttribute("data-freeform");c&&(a.style.zIndex="10"),this.setState({anchorEl:s[0],openedMenu:!!o||!!r&&!c,openedEditor:!!r&&c,selectedElems:s,labelElem:a,annotationIndex:l,annotation:t[l],selectionDetails:null})}}__init3(){this.handleHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,r=ee(o),i=te(o),s=i.hasAttribute("data-freeform");r.forEach(e=>{e.style.zIndex="20",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.7)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.55)")}),s?(i.style.zIndex="20",i.classList.contains("positive")?(i.style.backgroundColor="rgb(128, 255, 128)",i.style.setProperty("--before-border-color","rgb(153, 255, 153)")):i.classList.contains("negative")&&(i.style.backgroundColor="rgb(255, 179, 230)",i.style.setProperty("--before-border-color","rgb(255, 179, 230)"))):(i.style.zIndex="20",i.classList.contains("positive")?i.style.color="rgb(0, 77, 0)":i.classList.contains("negative")&&(i.style.color="rgb(153, 0, 102)"))}}__init4(){this.handleCancelHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,r=ee(o),i=te(o),s=i.hasAttribute("data-freeform");r.forEach(e=>{e.style.zIndex="",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)")}),s?(i.style.zIndex="",i.classList.contains("positive")?(i.style.backgroundColor="rgb(153, 255, 153)",i.style.removeProperty("--before-border-color")):i.classList.contains("negative")&&(i.style.backgroundColor="rgb(255, 204, 238)",i.style.removeProperty("--before-border-color"))):(i.style.zIndex="",i.classList.contains("positive")?i.style.color="rgb(0, 128, 0)":i.classList.contains("negative")&&(i.style.color="rgb(204, 0, 136)"))}}__init5(){this.handleClose=e=>{const{selectedElems:t,labelElem:n}=this.state;t.length&&!t[0].hasAttribute("data-id")&&Q(t,this.textRef),n&&(n.style.zIndex=""),this.setState({anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotationIndex:null,annotation:null}),J()}}__init6(){this.handleSelection=e=>{const t=window.getSelection();if(e.detail>2)J();else if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=e.toString(),o=this.textRef.contains(e.commonAncestorContainer);if(!t.isCollapsed&&""!==n&&o){const t=((e,t)=>{const n=document.createRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);const[,o]=Y(n),[,r]=Y(e),i=o.length;return{quote:r,start:i,end:i+r.length}})(e,this.textRef),n=X(e);this.setState({anchorEl:n[0],openedMenu:!0,selectedElems:n,selectionDetails:t})}}}}__init7(){this.deleteAnnotation=()=>{const{annotations:e,onChange:t}=this.props,{selectedElems:n,labelElem:o,annotationIndex:r,annotation:i}=this.state;(Z(i.label)?this.labelsRef:n[0]).removeChild(o),Q(n,this.textRef),e.splice(r,1),t(e),this.handleClose()}}__init8(){this.createDOMAnnotation=(e,t)=>{const{disabled:n}=this.props,{id:o,label:r,type:i}=t;(e||[]).forEach(e=>{e.dataset.id=o,e.className=`annotation ${i}`,e.style.position="relative",e.style.cursor="pointer","positive"===i?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":"negative"===i&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)"),e.onclick=!n&&this.handleClick,e.onmouseover=this.handleHover,e.onmouseout=this.handleCancelHover});const s=e&&e[0]||{},a=document.createElement("SPAN");if(a.dataset.annId=o,a.innerHTML=r,a.onclick=!n&&this.handleClick,a.onmouseover=this.handleHover,a.onmouseout=this.handleCancelHover,Z(r)){const e=(s.offsetTop?s.offsetTop:s.offsetParent.offsetTop)-this.textRef.scrollTop,t=this.textRef.offsetLeft+this.textRef.offsetWidth+8;a.dataset.freeform=!0,a.className=`sideAnnotation ${i}`,a.style.position="absolute",a.style.padding="4px",a.style.borderRadius="4px",a.style.marginLeft="8px",a.style.width="180px",a.style.whiteSpace="pre-wrap",a.style.wordBreak="break-word",a.style.border="2px solid #ffffff",a.style.fontSize="14px",a.style.fontStyle="normal",a.style.fontWeight="normal",a.style.top=`${e}px`,a.style.left=`${t}px`,"negative"===i?a.style.backgroundColor="rgb(255, 204, 238)":"positive"===i&&(a.style.backgroundColor="rgb(153, 255, 153)"),a.style.setProperty("--before-border-width","7px"),a.style.setProperty("--before-top","5px"),a.style.setProperty("--before-right","100%"),"negative"===i?a.style.setProperty("--before-border-color","rgb(255, 204, 238)"):"positive"===i&&a.style.setProperty("--before-border-color","rgb(153, 255, 153)"),this.labelsRef.appendChild(a)}else a.className=`annotationLabel ${i}`,a.style.backgroundColor="rgb(242, 242, 242)",a.style.padding="2px",a.style.position="absolute",a.style.userSelect="none",a.style.whiteSpace="nowrap",a.style.top="-10px",a.style.left="-2px",a.style.fontSize="12px",a.style.fontStyle="normal",a.style.fontWeight="normal",a.style.lineHeight="6px",a.style.webkitUserSelect="none",a.style.mozUserSelect="none",a.style.msUserSelect="none","positive"===i?a.style.color="rgb(0, 128, 0)":"negative"===i&&(a.style.color="rgb(204, 0, 136)"),s.appendChild(a)}}__init9(){this.createNewAnnotation=(e,t)=>{const{selectedElems:n,selectionDetails:o}=this.state,r={id:[o.start,o.end,(new Date).getTime()].join("-"),label:e,type:t,...o};return this.createDOMAnnotation(n,r),r}}__init10(){this.handleMenuClick=e=>{const{annotations:t,onChange:n}=this.props,{annotation:o,annotationIndex:r}=this.state,{type:i,text:s}=e;if(o){const e={...o,label:s,type:i},{type:n,label:a}=o;this.updateLabel(a,e,i!==n&&n),t.splice(r,1,e)}else{const e=this.createNewAnnotation(s,i);t.push(e)}n(t),this.handleClose()}}__init11(){this.editAnnotation=()=>{this.setState({openedMenu:!1,openedEditor:!0})}}__init12(){this.addAnnotation=e=>{const{annotations:t,onChange:n}=this.props,o=this.createNewAnnotation("",e),r=te(o.id);t.push(o),this.setState({openedMenu:!1,openedEditor:!0,annotationIndex:t.length-1,annotation:o,labelElem:r}),n(t)}}__init13(){this.updateLabel=(e,t,n)=>{const{selectedElems:o,labelElem:r}=this.state,{label:i,type:s}=t;Z(i)&&Z(e)||!Z(i)&&!Z(e)?(r.innerHTML=i,n&&(r.classList.remove(n),r.classList.add(s),o.forEach(e=>{e.classList.remove(n),e.classList.add(s)}))):Z(i)&&!Z(e)?(o[0].removeChild(r),this.createDOMAnnotation(o,t)):!Z(i)&&Z(e)&&(this.labelsRef.removeChild(r),this.createDOMAnnotation(o,t))}}__init14(){this.changeAnnotationType=e=>{const{annotations:t,onChange:n}=this.props,{annotationIndex:o,selectedElems:r}=this.state,{type:i,label:s}=t[o],a="positive"===i?"negative":"positive",l={...t[o],type:a,label:e};r.forEach(e=>{e.classList.remove(i),e.classList.add(a)}),this.updateLabel(s,l,i),t.splice(o,1,l),n(t),this.handleClose()}}__init15(){this.updateAnnotation=(e,t)=>{const{annotations:n,onChange:o}=this.props,{annotationIndex:r}=this.state,i={...n[r],label:t};this.updateLabel(e,i),n.splice(r,1,i),o(n)}}componentWillUnmount(){this.textRef.removeEventListener("scroll",this.adjustAnnotationsPosition)}render(){const{comment:e,customKeys:t,disabled:n,disabledMath:o,keypadMode:r,height:i,width:s,maxHeight:a,onCommentChange:l,predefinedAnnotations:c,text:d}=this.props,{anchorEl:p,annotation:u,openedMenu:h,openedEditor:f,selectionDetails:m}=this.state,g=p&&(p.offsetTop?p.offsetTop:p.offsetParent.offsetTop),y=this.textRef&&g?g-this.textRef.scrollTop-8:0;return B.createElement("div",null,B.createElement(ke,null,B.createElement(Se,{style:{width:s-34,minHeight:i,maxHeight:a},ref:e=>this.textRef=e,onMouseDown:n?()=>{}:J,onMouseUp:n?()=>{}:this.handleSelection,dangerouslySetInnerHTML:{__html:d}}),B.createElement(we,{ref:e=>this.labelsRef=e})),B.createElement(Re,{label:"Comment"},B.createElement(xe,{className:"prompt",markup:e||"",onChange:l,width:s&&(s+104).toString(),disabled:n,pluginProps:{math:{disabled:o,customKeys:t,keypadMode:r,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},textAlign:{disabled:!0}}})),B.createElement(ve,{anchorEl:p,open:h&&!n,annotations:c,isNewAnnotation:!!m,onClose:this.handleClose,onDelete:this.deleteAnnotation,onEdit:this.editAnnotation,onWrite:this.addAnnotation,onAnnotate:this.handleMenuClick}),B.createElement(de,{anchorEl:this.textRef,open:f&&!n,offset:y,value:u&&u.label||"",type:u&&u.type,onClose:this.handleClose,onDelete:this.deleteAnnotation,onSave:this.updateAnnotation,onTypeChange:this.changeAnnotationType}))}}Ae.__initStatic();const Te=e,{debounce:Pe}=o,Le=r,{Typography:Me}=t,{styled:Ie}=n,{color:$e}=i,{Feedback:Ne}=i,{Collapsible:De}=i,{PreviewPrompt:Oe}=i,{UiLayout:je}=i,He=l,We=Le("@pie-ui:extended-text-entry"),ze=Ie(je)({backgroundColor:$e.background(),color:$e.text()}),qe=Ie(Me)(({theme:e})=>({width:"100%",color:$e.text(),marginBottom:e.spacing(2),fontSize:"inherit"})),Ve=Ie("div")(({theme:e})=>({marginBottom:e.spacing(2)})),Ue=Ie(He)(({theme:e})=>({marginBottom:e.spacing(2),borderRadius:"4px"})),Fe=Ie("h2")({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"});class Be extends B.Component{constructor(...e){super(...e),Be.prototype.__init.call(this),Be.prototype.__init2.call(this)}static __initStatic(){this.propTypes={onValueChange:Te.func.isRequired,onAnnotationsChange:Te.func.isRequired,onCommentChange:Te.func.isRequired,model:Te.object,session:Te.shape({value:Te.string,annotations:Te.array,comment:Te.string}).isRequired}}__init(){this.changeSessionValue=Pe(this.props.onValueChange,1500)}__init2(){this.changeSessionComment=Pe(this.props.onCommentChange,1500)}render(){const{model:e,session:t,onAnnotationsChange:n}=this.props,{animationsDisabled:o,annotatorMode:r,customKeys:i,dimensions:s,disabled:a,disabledAnnotator:l,equationEditor:c,extraCSSRules:d,feedback:p,mathInput:u,playersToolbarPosition:h,predefinedAnnotations:f,prompt:m,spanishInput:g,specialInput:y,spellCheckEnabled:b,teacherInstructions:v}=e,{annotations:C,comment:_,value:x}=t,{width:E,height:S}=s||{},w="40vh",k={position:"top"===h?"top":"bottom"};We("[render] disabled? ",a);const R=B.createElement(Oe,{defaultClassName:"teacher-instructions",prompt:v}),A=[];return g&&A.push({language:"spanish"}),y&&A.push({language:"special"}),B.createElement(ze,{extraCSSRules:d,ref:e=>{this.containerRef=e}},B.createElement(Fe,null,"Constructed Response Question"),v&&B.createElement(Ve,null,o?R:B.createElement(De,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},R)),m&&B.createElement(qe,{component:"span"},B.createElement(Oe,{defaultClassName:"prompt",prompt:e.prompt})),r?B.createElement(Ae,{text:x||"",annotations:C||[],comment:_||"",predefinedAnnotations:f||[],onChange:n,onCommentChange:this.changeSessionComment,width:E,height:S,maxHeight:w,disabled:l,disabledMath:!u,customKeys:i,keypadMode:c}):B.createElement(Ue,{className:"response-area-editor",onChange:this.changeSessionValue,markup:x||"",maxWidth:E&&E.toString(),minWidth:"100px",minHeight:S&&S.toString(),maxHeight:w,disabled:a,highlightShape:!0,toolbarOpts:k,spellCheck:b,charactersLimit:5e4,autoWidthToolbar:!0,pluginProps:{math:{disabled:!u,customKeys:this.props.model.customKeys,keypadMode:this.props.model.equationEditor,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},table:{disabled:!0},textAlign:{disabled:!0},separateParagraphs:{disabled:!1},ul_list:{disabled:!0},ol_list:{disabled:!0}},languageCharactersProps:A}),p&&B.createElement(Ne,{correctness:"correct",feedback:p}))}}Be.__initStatic();var Ke,Ye=s;Ke=Ye.createRoot,Ye.hydrateRoot;var Ge={};Object.defineProperty(Ge,"__esModule",{value:!0});class Xe extends CustomEvent{constructor(e,t,n){super(Xe.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}Xe.TYPE="model-set";var Qe=Ge.ModelSetEvent=Xe;class Je extends CustomEvent{constructor(e,t){super(Je.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}Je.TYPE="session-changed";var Ze=Ge.SessionChangedEvent=Je;const et=r,{renderMath:tt}=a,nt=et("@pie-elements:extended-text-entry"),ot=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function rt(e){if("string"==typeof e)try{const t=ot.parseFromString(e,"text/html");return t.body.textContent}catch(t){return nt("tried to parse as dom and failed",e),e}}function it(e){const t=rt(e);return void 0!==t&&t.length>0}class st extends HTMLElement{constructor(){super(),this._model=null,this._session=null,this._root=null}setLangAttribute(){const e=this._model&&(this._model.language,1)?this._model.language:"",t=e?e.slice(0,2):"en";this.setAttribute("lang",t)}set model(e){this._model=e,this.dispatchEvent(new Qe(this.tagName.toLowerCase(),!1,!!this._model)),this.render()}set session(e){this._session=e,this.render()}get session(){return this._session}valueChange(e){this._session.value=e,this.dispatchEvent(new Ze(this.tagName.toLowerCase(),it(e))),this.render()}annotationsChange(e){this._session.annotations=e,this.dispatchEvent(new Ze(this.tagName.toLowerCase(),!0)),this.render()}commentChange(e){this._session.comment=e,this.dispatchEvent(new Ze(this.tagName.toLowerCase(),it(e))),this.render()}connectedCallback(){this.setAttribute("aria-label","Written Response Question"),this.setAttribute("role","region"),this.render()}render(){if(this._model&&this._session){let e=B.createElement(Be,{model:this._model,session:this._session,onValueChange:this.valueChange.bind(this),onAnnotationsChange:this.annotationsChange.bind(this),onCommentChange:this.commentChange.bind(this)});this.setLangAttribute(),this._root||(this._root=Ke(this)),this._root.render(e),queueMicrotask(()=>{tt(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{st as default,it as isComplete,rt as textContent};
1
+ import{_dll_react as e,_dll_prop_types as t,_dll_mui__material as n,_dll_mui__material_styles as o,_dll_debug as i,_dll_pie_lib__render_ui as s,_dll_react_dom as a}from"../../../@pie-lib/shared-module@^4.0.1/module/index.js";import{_dll_pie_lib__math_rendering as r}from"../../../@pie-lib/math-rendering-module@^4.0.7/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^6.1.2/module/index.js";import{_dll_pie_lib__config_ui as d}from"../../../@pie-lib/config-module@^3.0.1/module/index.js";var c="object"==typeof global&&global&&global.Object===Object&&global,p="object"==typeof self&&self&&self.Object===Object&&self,h=c||p||Function("return this")(),u=h.Symbol,m=Object.prototype,g=m.hasOwnProperty,f=m.toString,b=u?u.toStringTag:void 0;var y=Object.prototype.toString;var v=u?u.toStringTag:void 0;function C(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":v&&v in Object(e)?function(e){var t=g.call(e,b),n=e[b];try{e[b]=void 0;var o=!0}catch(e){}var i=f.call(e);return o&&(t?e[b]=n:delete e[b]),i}(e):function(e){return y.call(e)}(e)}var x=/\s/;var _=/^\s+/;function E(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&x.test(e.charAt(t)););return t}(e)+1).replace(_,""):e}function w(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var S=/^[-+]0x[0-9a-f]+$/i,A=/^0b[01]+$/i,k=/^0o[0-7]+$/i,T=parseInt;function R(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==C(e)}(e))return NaN;if(w(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=w(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=E(e);var n=A.test(e);return n||k.test(e)?T(e.slice(2),n?2:8):S.test(e)?NaN:+e}var M=function(){return h.Date.now()},L=Math.max,P=Math.min;function N(e,t,n){var o,i,s,a,r,l,d=0,c=!1,p=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function u(t){var n=o,s=i;return o=i=void 0,d=t,a=e.apply(s,n)}function m(e){var n=e-l;return void 0===l||n>=t||n<0||p&&e-d>=s}function g(){var e=M();if(m(e))return f(e);r=setTimeout(g,function(e){var n=t-(e-l);return p?P(n,s-(e-d)):n}(e))}function f(e){return r=void 0,h&&o?u(e):(o=i=void 0,a)}function b(){var e=M(),n=m(e);if(o=arguments,i=this,l=e,n){if(void 0===r)return function(e){return d=e,r=setTimeout(g,t),c?u(e):a}(l);if(p)return clearTimeout(r),r=setTimeout(g,t),u(l)}return void 0===r&&(r=setTimeout(g,t)),a}return t=R(t)||0,w(n)&&(c=!!n.leading,s=(p="maxWait"in n)?L(R(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h),b.cancel=function(){void 0!==r&&clearTimeout(r),d=0,o=l=i=r=void 0},b.flush=function(){return void 0===r?a:f(M())},b}const I=(e,t,n)=>{const o=n||[],i=o.reduce((e,t)=>e+t.textContent.length,0);let s=!0;if(i>t)return!1;for(e&&(3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&o.push(e),e=e.firstChild);e&&s;)s=I(e,t,o),e=e.nextSibling;return o},D=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o,startOffset:i,endOffset:s}=e,a=[];let r=!1,l=!1,d="";const c=e=>{const{nodeValue:t,childNodes:p}=e;e===n&&e===o?(t&&(d+=t.substring(i,s)),r=l=!0):e===n?(t&&(d+=t.substring(i)),r=!0):e===o?(t&&(d+=t.substring(0,s)),l=!0):e&&3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&t&&r&&!l&&(d+=t,a.push(e)),p.forEach(e=>{l||c(e)})};return c(t),[a,d]},j=e=>{const t=document.createElement("SPAN");return e.surroundContents(t),t},O=e=>{if(e.startContainer===e.endContainer)return[j(e)];const[t]=D(e),n=document.createRange();n.selectNodeContents(e.startContainer),n.setStart(e.startContainer,e.startOffset);const o=j(n),i=document.createRange();i.selectNode(e.endContainer),i.setEnd(e.endContainer,e.endOffset);const s=j(i);return[o,...t.map(e=>{const t=document.createElement("SPAN");return e.parentNode.insertBefore(t,e),t.appendChild(e),t}),s]},W=(e,t)=>{(e||[]).forEach(e=>{const t=e.parentNode,n=e.childNodes,o=n.length;if(o>0)for(let i=0;i<o;i++)t.insertBefore(n[0],e);else t.insertBefore(document.createTextNode(e.textContent),e);t.removeChild(e)}),t.normalize()},$=()=>{document.getSelection?(document.getSelection().removeAllRanges(),document.getSelection().addRange(document.createRange())):window.getSelection?window.getSelection().removeAllRanges?(window.getSelection().removeAllRanges(),window.getSelection().addRange(document.createRange())):window.getSelection().empty&&window.getSelection().empty():document.selection&&document.selection.empty()},H=e=>e.length>=20||-1!==e.search(/\n|\r|\r\n/),z=e=>Array.from(document.querySelectorAll(`[data-id='${e}']`)),q=e=>document.querySelector(`[data-ann-id='${e}']`),B=e,F=t,{Popover:K}=n,{TextField:U}=n,{styled:V}=o,Y=V(K)(({theme:e,annotationType:t})=>({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginLeft:"16px","&::before":{position:"absolute",right:"100%",top:"13px",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderRightColor:e.palette.grey[100]},..."negative"===t&&{"&::before":{borderRightColor:"rgb(255, 204, 238) !important"}},..."positive"===t&&{"&::before":{borderRightColor:"rgb(153, 255, 153) !important"}}}})),G=V("div")(({theme:e,annotationType:t})=>({width:"200px",overflow:"hidden",borderRadius:"4px",backgroundColor:"#ffffff",border:`4px solid ${e.palette.grey[100]}`,..."negative"===t&&{borderColor:"rgb(255, 204, 238) !important"},..."positive"===t&&{borderColor:"rgb(153, 255, 153) !important"}})),X=V("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),Q=V("div")(({theme:e,variant:t,annotationType:n})=>({flexGrow:1,width:"28%",textAlign:"center",padding:"4px",cursor:"pointer","&:not(:nth-child(3n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}},..."typeChange"===t&&"negative"===n&&{"&:hover":{backgroundColor:"rgb(153, 255, 153) !important"}},..."typeChange"===t&&"positive"===n&&{"&:hover":{backgroundColor:"rgb(255, 204, 238) !important"}}}));class J extends B.Component{static __initStatic(){this.propTypes={anchorEl:F.object,open:F.bool,offset:F.number,value:F.string,type:F.string,onClose:F.func,onDelete:F.func,onSave:F.func,onTypeChange:F.func}}constructor(e){super(e),J.prototype.__init.call(this),J.prototype.__init2.call(this),J.prototype.__init3.call(this),this.state={value:e.value}}UNSAFE_componentWillReceiveProps(e){const{value:t}=e,{value:n}=this.props;t!==n&&this.setState({value:t})}__init(){this.onValueChange=e=>this.setState({value:e.target.value})}__init2(){this.handleSave=()=>{const{value:e,onSave:t,onClose:n,onDelete:o}=this.props,{value:i}=this.state;""===i&&o(),e!==i&&t(e,i),this.setState({value:""}),n()}}__init3(){this.handleTypeChange=()=>{const{onTypeChange:e,onDelete:t}=this.props,{value:n}=this.state;""===n?t():e(n),this.setState({value:""})}}render(){const{anchorEl:e,offset:t,onDelete:n,open:o,type:i}=this.props,{value:s}=this.state;return B.createElement(Y,{anchorEl:e,elevation:2,open:o,onClose:this.handleSave,annotationType:i,style:{marginTop:`${t}px`,transition:"margin-top 2s ease-out"},transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"}},B.createElement(G,{annotationType:i},B.createElement(U,{id:"annotation-editor",style:{padding:"2px 5px",width:"95%"},autoFocus:!0,multiline:!0,rows:1,maxRows:4,value:s,onChange:this.onValueChange,InputProps:{disableUnderline:!0}}),B.createElement(X,null,B.createElement(Q,{onClick:n},"Delete"),B.createElement(Q,{variant:"typeChange",annotationType:i,onClick:this.handleTypeChange},"negative"===i?"Green":"Pink"),B.createElement(Q,{onClick:this.handleSave},"Save"))))}}J.__initStatic();const Z=e,ee=t,{styled:te}=o,{Popover:ne}=n,oe=te(ne)({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginTop:"-16px","&::after":{position:"absolute",left:"calc(50% - 7px)",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderTopColor:"black"}}}),ie=te("div")(({theme:e})=>({width:"300px",overflow:"hidden",borderRadius:"4px",backgroundColor:e.palette.common.white,border:`2px solid ${e.palette.grey[100]}`})),se=te("div")({display:"flex",flexWrap:"wrap"}),ae=te("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),re=te("div")(({theme:e,variant:t})=>({width:"22%",textAlign:"center",padding:"4px",cursor:"pointer",borderBottom:`1px solid ${e.palette.grey[100]}`,"&:not(:nth-child(4n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:nth-child(4n)":{flexGrow:1},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}}}));class le extends Z.Component{static __initStatic(){this.propTypes={anchorEl:ee.object,open:ee.bool,annotations:ee.array,isNewAnnotation:ee.bool,onClose:ee.func,onDelete:ee.func,onEdit:ee.func,onWrite:ee.func,onAnnotate:ee.func}}render(){const{anchorEl:e,annotations:t,isNewAnnotation:n,onAnnotate:o,onClose:i,onEdit:s,onDelete:a,onWrite:r,open:l}=this.props;return Z.createElement(oe,{anchorEl:e,open:l,onClose:i,elevation:5,transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}},Z.createElement(ie,null,Z.createElement(se,null,t.map((e,t)=>Z.createElement(re,{key:`annotation-${t}`,variant:e.type,onClick:()=>o(e)},e.label))),Z.createElement(ae,null,Z.createElement(re,{onClick:i},"Cancel"),Z.createElement(re,{style:{pointerEvents:"none"}}),n?Z.createElement(Z.Fragment,null,Z.createElement(re,{variant:"positive",onClick:()=>r("positive")},"Write"),Z.createElement(re,{variant:"negative",onClick:()=>r("negative")},"Write")):Z.createElement(Z.Fragment,null,Z.createElement(re,{onClick:a},"Delete"),Z.createElement(re,{onClick:s},"Edit")))))}}le.__initStatic();const de=e,{styled:ce}=o,pe=t,he=l,{InputContainer:ue}=d,me=ce("div")({padding:"10px 120px 10px 16px",backgroundColor:"rgba(0, 0, 0, 0.06)",border:"1px solid #ccc",borderRadius:"4px",overflowY:"scroll",lineHeight:"36px",whiteSpace:"pre-wrap",overflowWrap:"break-word","& p":{margin:0},"& span[data-latex]":{userSelect:"none","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none"}}),ge=ce("div")({width:"230px"}),fe=ce("div")({position:"relative",overflowX:"hidden",display:"flex"}),be=ce(ue)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2),marginTop:e.spacing(2),width:"100%"}));if(!document.getElementById("annotation-editor-styles")){const e=document.createElement("style");e.id="annotation-editor-styles",e.textContent='\n .sideAnnotation:before {\n position: absolute;\n right: var(--before-right, 100%);\n top: var(--before-top, 5px);\n border: solid transparent;\n content: "";\n height: 0;\n width: 0;\n pointer-events: none;\n border-width: var(--before-border-width, 7px);\n border-right-color: var(--before-border-color, rgb(153, 255, 153));\n }\n',document.head.appendChild(e)}class ye extends de.Component{static __initStatic(){this.propTypes={text:pe.string,comment:pe.string,annotations:pe.array,predefinedAnnotations:pe.array,onChange:pe.func.isRequired,onCommentChange:pe.func.isRequired,width:pe.number,height:pe.number,maxHeight:pe.string,disabled:pe.bool,disabledMath:pe.bool,customKeys:pe.array,keypadMode:pe.string}}constructor(e){super(e),ye.prototype.__init.call(this),ye.prototype.__init2.call(this),ye.prototype.__init3.call(this),ye.prototype.__init4.call(this),ye.prototype.__init5.call(this),ye.prototype.__init6.call(this),ye.prototype.__init7.call(this),ye.prototype.__init8.call(this),ye.prototype.__init9.call(this),ye.prototype.__init10.call(this),ye.prototype.__init11.call(this),ye.prototype.__init12.call(this),ye.prototype.__init13.call(this),ye.prototype.__init14.call(this),ye.prototype.__init15.call(this),this.state={anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotation:null,annotationIndex:null}}componentDidMount(){const{annotations:e,text:t}=this.props;t&&e.forEach(e=>{const[t,n]=((e,t,n)=>{const o=I(n,t),i=[];let s=0;return o.forEach(n=>{const o=s+n.textContent.length;[e,t].forEach(e=>{s<=e&&e<o&&i.push({node:n,offset:e-s})}),s=o}),i})(e.start,e.end,this.textRef);if(t&&n){const o=document.createRange();o.setStart(t.node,t.offset),o.setEnd(n.node,n.offset);const i=O(o);this.createDOMAnnotation(i,e)}}),this.textRef&&(this.adjustAnnotationsPosition(),this.textRef.addEventListener("scroll",this.adjustAnnotationsPosition))}__init(){this.adjustAnnotationsPosition=()=>{if(this.textRef&&this.labelsRef){const e=this.textRef.offsetLeft+this.textRef.offsetWidth+8;Array.from(this.labelsRef.children).forEach(t=>{const n=z(t.dataset.annId),o=(n[0].offsetTop?n[0].offsetTop:n[0].offsetParent.offsetTop)-this.textRef.scrollTop-6;t.style.top=`${o}px`,t.style.left=`${e}px`})}}}__init2(){this.handleClick=e=>{const{annotations:t}=this.props,{selectionDetails:n}=this.state;if(n)return;const{id:o,annId:i}=e.target.dataset,s=o||i,a=z(s),r=q(s),l=t.findIndex(e=>e.id===s),d=r.hasAttribute("data-freeform");d&&(r.style.zIndex="10"),this.setState({anchorEl:a[0],openedMenu:!!o||!!i&&!d,openedEditor:!!i&&d,selectedElems:a,labelElem:r,annotationIndex:l,annotation:t[l],selectionDetails:null})}}__init3(){this.handleHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,i=z(o),s=q(o),a=s.hasAttribute("data-freeform");i.forEach(e=>{e.style.zIndex="20",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.7)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.55)")}),a?(s.style.zIndex="20",s.classList.contains("positive")?(s.style.backgroundColor="rgb(128, 255, 128)",s.style.setProperty("--before-border-color","rgb(153, 255, 153)")):s.classList.contains("negative")&&(s.style.backgroundColor="rgb(255, 179, 230)",s.style.setProperty("--before-border-color","rgb(255, 179, 230)"))):(s.style.zIndex="20",s.classList.contains("positive")?s.style.color="rgb(0, 77, 0)":s.classList.contains("negative")&&(s.style.color="rgb(153, 0, 102)"))}}__init4(){this.handleCancelHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,i=z(o),s=q(o),a=s.hasAttribute("data-freeform");i.forEach(e=>{e.style.zIndex="",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)")}),a?(s.style.zIndex="",s.classList.contains("positive")?(s.style.backgroundColor="rgb(153, 255, 153)",s.style.removeProperty("--before-border-color")):s.classList.contains("negative")&&(s.style.backgroundColor="rgb(255, 204, 238)",s.style.removeProperty("--before-border-color"))):(s.style.zIndex="",s.classList.contains("positive")?s.style.color="rgb(0, 128, 0)":s.classList.contains("negative")&&(s.style.color="rgb(204, 0, 136)"))}}__init5(){this.handleClose=e=>{const{selectedElems:t,labelElem:n}=this.state;t.length&&!t[0].hasAttribute("data-id")&&W(t,this.textRef),n&&(n.style.zIndex=""),this.setState({anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotationIndex:null,annotation:null}),$()}}__init6(){this.handleSelection=e=>{const t=window.getSelection();if(e.detail>2)$();else if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=e.toString(),o=this.textRef.contains(e.commonAncestorContainer);if(!t.isCollapsed&&""!==n&&o){const t=((e,t)=>{const n=document.createRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);const[,o]=D(n),[,i]=D(e),s=o.length;return{quote:i,start:s,end:s+i.length}})(e,this.textRef),n=O(e);this.setState({anchorEl:n[0],openedMenu:!0,selectedElems:n,selectionDetails:t})}}}}__init7(){this.deleteAnnotation=()=>{const{annotations:e,onChange:t}=this.props,{selectedElems:n,labelElem:o,annotationIndex:i,annotation:s}=this.state;(H(s.label)?this.labelsRef:n[0]).removeChild(o),W(n,this.textRef),e.splice(i,1),t(e),this.handleClose()}}__init8(){this.createDOMAnnotation=(e,t)=>{const{disabled:n}=this.props,{id:o,label:i,type:s}=t;(e||[]).forEach(e=>{e.dataset.id=o,e.className=`annotation ${s}`,e.style.position="relative",e.style.cursor="pointer","positive"===s?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":"negative"===s&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)"),e.onclick=!n&&this.handleClick,e.onmouseover=this.handleHover,e.onmouseout=this.handleCancelHover});const a=e&&e[0]||{},r=document.createElement("SPAN");if(r.dataset.annId=o,r.innerHTML=i,r.onclick=!n&&this.handleClick,r.onmouseover=this.handleHover,r.onmouseout=this.handleCancelHover,H(i)){const e=(a.offsetTop?a.offsetTop:a.offsetParent.offsetTop)-this.textRef.scrollTop,t=this.textRef.offsetLeft+this.textRef.offsetWidth+8;r.dataset.freeform=!0,r.className=`sideAnnotation ${s}`,r.style.position="absolute",r.style.padding="4px",r.style.borderRadius="4px",r.style.marginLeft="8px",r.style.width="180px",r.style.whiteSpace="pre-wrap",r.style.wordBreak="break-word",r.style.border="2px solid #ffffff",r.style.fontSize="14px",r.style.fontStyle="normal",r.style.fontWeight="normal",r.style.top=`${e}px`,r.style.left=`${t}px`,"negative"===s?r.style.backgroundColor="rgb(255, 204, 238)":"positive"===s&&(r.style.backgroundColor="rgb(153, 255, 153)"),r.style.setProperty("--before-border-width","7px"),r.style.setProperty("--before-top","5px"),r.style.setProperty("--before-right","100%"),"negative"===s?r.style.setProperty("--before-border-color","rgb(255, 204, 238)"):"positive"===s&&r.style.setProperty("--before-border-color","rgb(153, 255, 153)"),this.labelsRef.appendChild(r)}else r.className=`annotationLabel ${s}`,r.style.backgroundColor="rgb(242, 242, 242)",r.style.padding="2px",r.style.position="absolute",r.style.userSelect="none",r.style.whiteSpace="nowrap",r.style.top="-10px",r.style.left="-2px",r.style.fontSize="12px",r.style.fontStyle="normal",r.style.fontWeight="normal",r.style.lineHeight="6px",r.style.webkitUserSelect="none",r.style.mozUserSelect="none",r.style.msUserSelect="none","positive"===s?r.style.color="rgb(0, 128, 0)":"negative"===s&&(r.style.color="rgb(204, 0, 136)"),a.appendChild(r)}}__init9(){this.createNewAnnotation=(e,t)=>{const{selectedElems:n,selectionDetails:o}=this.state,i={id:[o.start,o.end,(new Date).getTime()].join("-"),label:e,type:t,...o};return this.createDOMAnnotation(n,i),i}}__init10(){this.handleMenuClick=e=>{const{annotations:t,onChange:n}=this.props,{annotation:o,annotationIndex:i}=this.state,{type:s,text:a}=e;if(o){const e={...o,label:a,type:s},{type:n,label:r}=o;this.updateLabel(r,e,s!==n&&n),t.splice(i,1,e)}else{const e=this.createNewAnnotation(a,s);t.push(e)}n(t),this.handleClose()}}__init11(){this.editAnnotation=()=>{this.setState({openedMenu:!1,openedEditor:!0})}}__init12(){this.addAnnotation=e=>{const{annotations:t,onChange:n}=this.props,o=this.createNewAnnotation("",e),i=q(o.id);t.push(o),this.setState({openedMenu:!1,openedEditor:!0,annotationIndex:t.length-1,annotation:o,labelElem:i}),n(t)}}__init13(){this.updateLabel=(e,t,n)=>{const{selectedElems:o,labelElem:i}=this.state,{label:s,type:a}=t;H(s)&&H(e)||!H(s)&&!H(e)?(i.innerHTML=s,n&&(i.classList.remove(n),i.classList.add(a),o.forEach(e=>{e.classList.remove(n),e.classList.add(a)}))):H(s)&&!H(e)?(o[0].removeChild(i),this.createDOMAnnotation(o,t)):!H(s)&&H(e)&&(this.labelsRef.removeChild(i),this.createDOMAnnotation(o,t))}}__init14(){this.changeAnnotationType=e=>{const{annotations:t,onChange:n}=this.props,{annotationIndex:o,selectedElems:i}=this.state,{type:s,label:a}=t[o],r="positive"===s?"negative":"positive",l={...t[o],type:r,label:e};i.forEach(e=>{e.classList.remove(s),e.classList.add(r)}),this.updateLabel(a,l,s),t.splice(o,1,l),n(t),this.handleClose()}}__init15(){this.updateAnnotation=(e,t)=>{const{annotations:n,onChange:o}=this.props,{annotationIndex:i}=this.state,s={...n[i],label:t};this.updateLabel(e,s),n.splice(i,1,s),o(n)}}componentWillUnmount(){this.textRef.removeEventListener("scroll",this.adjustAnnotationsPosition)}render(){const{comment:e,customKeys:t,disabled:n,disabledMath:o,keypadMode:i,height:s,width:a,maxHeight:r,onCommentChange:l,predefinedAnnotations:d,text:c}=this.props,{anchorEl:p,annotation:h,openedMenu:u,openedEditor:m,selectionDetails:g}=this.state,f=p&&(p.offsetTop?p.offsetTop:p.offsetParent.offsetTop),b=this.textRef&&f?f-this.textRef.scrollTop-8:0;return de.createElement("div",null,de.createElement(fe,null,de.createElement(me,{style:{width:a-34,minHeight:s,maxHeight:r},ref:e=>this.textRef=e,onMouseDown:n?()=>{}:$,onMouseUp:n?()=>{}:this.handleSelection,dangerouslySetInnerHTML:{__html:c}}),de.createElement(ge,{ref:e=>this.labelsRef=e})),de.createElement(be,{label:"Comment"},de.createElement(he,{className:"prompt",markup:e||"",onChange:l,width:a&&(a+104).toString(),disabled:n,pluginProps:{math:{disabled:o,customKeys:t,keypadMode:i,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},textAlign:{disabled:!0}}})),de.createElement(le,{anchorEl:p,open:u&&!n,annotations:d,isNewAnnotation:!!g,onClose:this.handleClose,onDelete:this.deleteAnnotation,onEdit:this.editAnnotation,onWrite:this.addAnnotation,onAnnotate:this.handleMenuClick}),de.createElement(J,{anchorEl:this.textRef,open:m&&!n,offset:b,value:h&&h.label||"",type:h&&h.type,onClose:this.handleClose,onDelete:this.deleteAnnotation,onSave:this.updateAnnotation,onTypeChange:this.changeAnnotationType}))}}ye.__initStatic();const ve=e,Ce=t,xe=i,{Typography:_e}=n,{styled:Ee}=o,{color:we}=s,{Feedback:Se}=s,{Collapsible:Ae}=s,{PreviewPrompt:ke}=s,{UiLayout:Te}=s,Re=l,Me=xe("@pie-ui:extended-text-entry"),Le=Ee(Te)({backgroundColor:we.background(),color:we.text()}),Pe=Ee(_e)(({theme:e})=>({width:"100%",color:we.text(),marginBottom:e.spacing(2),fontSize:"inherit"})),Ne=Ee("div")(({theme:e})=>({marginBottom:e.spacing(2)})),Ie=Ee(Re)(({theme:e})=>({marginBottom:e.spacing(2),borderRadius:"4px"})),De=Ee("h2")({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"});class je extends ve.Component{constructor(...e){super(...e),je.prototype.__init.call(this),je.prototype.__init2.call(this)}static __initStatic(){this.propTypes={onValueChange:Ce.func.isRequired,onAnnotationsChange:Ce.func.isRequired,onCommentChange:Ce.func.isRequired,model:Ce.object,session:Ce.shape({value:Ce.string,annotations:Ce.array,comment:Ce.string}).isRequired}}__init(){this.changeSessionValue=N(this.props.onValueChange,1500)}__init2(){this.changeSessionComment=N(this.props.onCommentChange,1500)}render(){const{model:e,session:t,onAnnotationsChange:n}=this.props,{animationsDisabled:o,annotatorMode:i,customKeys:s,dimensions:a,disabled:r,disabledAnnotator:l,equationEditor:d,extraCSSRules:c,feedback:p,mathInput:h,playersToolbarPosition:u,predefinedAnnotations:m,prompt:g,spanishInput:f,specialInput:b,spellCheckEnabled:y,teacherInstructions:v}=e,{annotations:C,comment:x,value:_}=t,{width:E,height:w}=a||{},S="40vh",A={position:"top"===u?"top":"bottom"};Me("[render] disabled? ",r);const k=ve.createElement(ke,{defaultClassName:"teacher-instructions",prompt:v}),T=[];return f&&T.push({language:"spanish"}),b&&T.push({language:"special"}),ve.createElement(Le,{extraCSSRules:c,ref:e=>{this.containerRef=e}},ve.createElement(De,null,"Constructed Response Question"),v&&ve.createElement(Ne,null,o?k:ve.createElement(Ae,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},k)),g&&ve.createElement(Pe,{component:"span"},ve.createElement(ke,{defaultClassName:"prompt",prompt:e.prompt})),i?ve.createElement(ye,{text:_||"",annotations:C||[],comment:x||"",predefinedAnnotations:m||[],onChange:n,onCommentChange:this.changeSessionComment,width:E,height:w,maxHeight:S,disabled:l,disabledMath:!h,customKeys:s,keypadMode:d}):ve.createElement(Ie,{className:"response-area-editor",onChange:this.changeSessionValue,markup:_||"",maxWidth:E&&E.toString(),minWidth:"100px",minHeight:w&&w.toString(),maxHeight:S,disabled:r,highlightShape:!0,toolbarOpts:A,spellCheck:y,charactersLimit:5e4,autoWidthToolbar:!0,pluginProps:{math:{disabled:!h,customKeys:this.props.model.customKeys,keypadMode:this.props.model.equationEditor,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},table:{disabled:!0},textAlign:{disabled:!0},separateParagraphs:{disabled:!1},ul_list:{disabled:!0},ol_list:{disabled:!0}},languageCharactersProps:T}),p&&ve.createElement(Se,{correctness:"correct",feedback:p}))}}je.__initStatic();var Oe,We=a;Oe=We.createRoot,We.hydrateRoot;var $e={};Object.defineProperty($e,"__esModule",{value:!0});class He extends CustomEvent{constructor(e,t,n){super(He.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}He.TYPE="model-set";var ze=$e.ModelSetEvent=He;class qe extends CustomEvent{constructor(e,t){super(qe.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}qe.TYPE="session-changed";var Be=$e.SessionChangedEvent=qe;const Fe=e,Ke=i,{renderMath:Ue}=r,Ve=Ke("@pie-elements:extended-text-entry"),Ye=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function Ge(e){if("string"==typeof e)try{const t=Ye.parseFromString(e,"text/html");return t.body.textContent}catch(t){return Ve("tried to parse as dom and failed",e),e}}function Xe(e){const t=Ge(e);return void 0!==t&&t.length>0}class Qe extends HTMLElement{constructor(){super(),this._model=null,this._session=null,this._root=null}setLangAttribute(){const e=this._model&&(this._model.language,1)?this._model.language:"",t=e?e.slice(0,2):"en";this.setAttribute("lang",t)}set model(e){this._model=e,this.dispatchEvent(new ze(this.tagName.toLowerCase(),!1,!!this._model)),this.render()}set session(e){this._session=e,this.render()}get session(){return this._session}valueChange(e){this._session.value=e,this.dispatchEvent(new Be(this.tagName.toLowerCase(),Xe(e))),this.render()}annotationsChange(e){this._session.annotations=e,this.dispatchEvent(new Be(this.tagName.toLowerCase(),!0)),this.render()}commentChange(e){this._session.comment=e,this.dispatchEvent(new Be(this.tagName.toLowerCase(),Xe(e))),this.render()}connectedCallback(){this.setAttribute("aria-label","Written Response Question"),this.setAttribute("role","region"),this.render()}render(){if(this._model&&this._session){let e=Fe.createElement(je,{model:this._model,session:this._session,onValueChange:this.valueChange.bind(this),onAnnotationsChange:this.annotationsChange.bind(this),onCommentChange:this.commentChange.bind(this)});this.setLangAttribute(),this._root||(this._root=Oe(this)),this._root.render(e),queueMicrotask(()=>{Ue(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{Qe as default,Xe as isComplete,Ge as textContent};
package/module/index.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/extended-text-entry@14.0.0-beta.1</title>
5
+ <title>@pie-element/extended-text-entry@14.1.0-next.0</title>
6
6
  <script
7
7
  type="module"
8
8
  src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry",
3
- "version": "14.0.0-beta.1",
3
+ "version": "14.1.0-next.0",
4
4
  "modules": [
5
5
  {
6
6
  "name": "@pie-lib/shared-module",
7
- "version": "^3.0.5"
7
+ "version": "^4.0.1"
8
8
  },
9
9
  {
10
10
  "name": "@pie-lib/math-rendering-module",
11
- "version": "^4.0.5"
11
+ "version": "^4.0.7"
12
12
  },
13
13
  {
14
14
  "name": "@pie-lib/editable-html-module",
15
- "version": "^6.0.5"
15
+ "version": "^6.1.2"
16
16
  },
17
17
  {
18
18
  "name": "@pie-lib/config-module",
19
- "version": "^3.0.0"
19
+ "version": "^3.0.1"
20
20
  }
21
21
  ]
22
22
  }
package/module/print.html CHANGED
@@ -2,7 +2,7 @@
2
2
  <!doctype html>
3
3
  <html>
4
4
  <head>
5
- <title>@pie-element/extended-text-entry@14.0.0-beta.1</title>
5
+ <title>@pie-element/extended-text-entry@14.1.0-next.0</title>
6
6
  <link
7
7
  href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
8
8
  rel="stylesheet"
@@ -0,0 +1 @@
1
+ import{_dll_react_dom as e,_dll_react as t,_dll_prop_types as n,_dll_mui__material as o,_dll_mui__material_styles as i,_dll_debug as a,_dll_pie_lib__render_ui as s}from"../../../@pie-lib/shared-module@^4.0.1/module/index.js";import{_dll_pie_lib__math_rendering as r}from"../../../@pie-lib/math-rendering-module@^4.0.7/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^6.1.2/module/index.js";import{_dll_pie_lib__config_ui as d}from"../../../@pie-lib/config-module@^3.0.1/module/index.js";var c,p=e;c=p.createRoot,p.hydrateRoot;var h="object"==typeof global&&global&&global.Object===Object&&global,u="object"==typeof self&&self&&self.Object===Object&&self,m=h||u||Function("return this")(),g=m.Symbol,f=Object.prototype,b=f.hasOwnProperty,y=f.toString,v=g?g.toStringTag:void 0;var C=Object.prototype.toString;var x=g?g.toStringTag:void 0;function _(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":x&&x in Object(e)?function(e){var t=b.call(e,v),n=e[v];try{e[v]=void 0;var o=!0}catch(e){}var i=y.call(e);return o&&(t?e[v]=n:delete e[v]),i}(e):function(e){return C.call(e)}(e)}var E=/\s/;var w=/^\s+/;function S(e){return e?e.slice(0,function(e){for(var t=e.length;t--&&E.test(e.charAt(t)););return t}(e)+1).replace(w,""):e}function k(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}var A=/^[-+]0x[0-9a-f]+$/i,R=/^0b[01]+$/i,T=/^0o[0-7]+$/i,M=parseInt;function I(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return null!=e&&"object"==typeof e}(e)&&"[object Symbol]"==_(e)}(e))return NaN;if(k(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=k(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=S(e);var n=R.test(e);return n||T.test(e)?M(e.slice(2),n?2:8):A.test(e)?NaN:+e}var L=function(){return m.Date.now()},P=Math.max,N=Math.min;function D(e,t,n){var o,i,a,s,r,l,d=0,c=!1,p=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function u(t){var n=o,a=i;return o=i=void 0,d=t,s=e.apply(a,n)}function m(e){var n=e-l;return void 0===l||n>=t||n<0||p&&e-d>=a}function g(){var e=L();if(m(e))return f(e);r=setTimeout(g,function(e){var n=t-(e-l);return p?N(n,a-(e-d)):n}(e))}function f(e){return r=void 0,h&&o?u(e):(o=i=void 0,s)}function b(){var e=L(),n=m(e);if(o=arguments,i=this,l=e,n){if(void 0===r)return function(e){return d=e,r=setTimeout(g,t),c?u(e):s}(l);if(p)return clearTimeout(r),r=setTimeout(g,t),u(l)}return void 0===r&&(r=setTimeout(g,t)),s}return t=I(t)||0,k(n)&&(c=!!n.leading,a=(p="maxWait"in n)?P(I(n.maxWait)||0,t):a,h="trailing"in n?!!n.trailing:h),b.cancel=function(){void 0!==r&&clearTimeout(r),d=0,o=l=i=r=void 0},b.flush=function(){return void 0===r?s:f(L())},b}const j=(e,t,n)=>{const o=n||[],i=o.reduce((e,t)=>e+t.textContent.length,0);let a=!0;if(i>t)return!1;for(e&&(3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&o.push(e),e=e.firstChild);e&&a;)a=j(e,t,o),e=e.nextSibling;return o},O=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o,startOffset:i,endOffset:a}=e,s=[];let r=!1,l=!1,d="";const c=e=>{const{nodeValue:t,childNodes:p}=e;e===n&&e===o?(t&&(d+=t.substring(i,a)),r=l=!0):e===n?(t&&(d+=t.substring(i)),r=!0):e===o?(t&&(d+=t.substring(0,a)),l=!0):e&&3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&t&&r&&!l&&(d+=t,s.push(e)),p.forEach(e=>{l||c(e)})};return c(t),[s,d]},W=e=>{const t=document.createElement("SPAN");return e.surroundContents(t),t},$=e=>{if(e.startContainer===e.endContainer)return[W(e)];const[t]=O(e),n=document.createRange();n.selectNodeContents(e.startContainer),n.setStart(e.startContainer,e.startOffset);const o=W(n),i=document.createRange();i.selectNode(e.endContainer),i.setEnd(e.endContainer,e.endOffset);const a=W(i);return[o,...t.map(e=>{const t=document.createElement("SPAN");return e.parentNode.insertBefore(t,e),t.appendChild(e),t}),a]},H=(e,t)=>{(e||[]).forEach(e=>{const t=e.parentNode,n=e.childNodes,o=n.length;if(o>0)for(let i=0;i<o;i++)t.insertBefore(n[0],e);else t.insertBefore(document.createTextNode(e.textContent),e);t.removeChild(e)}),t.normalize()},z=()=>{document.getSelection?(document.getSelection().removeAllRanges(),document.getSelection().addRange(document.createRange())):window.getSelection?window.getSelection().removeAllRanges?(window.getSelection().removeAllRanges(),window.getSelection().addRange(document.createRange())):window.getSelection().empty&&window.getSelection().empty():document.selection&&document.selection.empty()},q=e=>e.length>=20||-1!==e.search(/\n|\r|\r\n/),B=e=>Array.from(document.querySelectorAll(`[data-id='${e}']`)),K=e=>document.querySelector(`[data-ann-id='${e}']`),U=t,V=n,{Popover:F}=o,{TextField:G}=o,{styled:X}=i,Y=X(F)(({theme:e,annotationType:t})=>({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginLeft:"16px","&::before":{position:"absolute",right:"100%",top:"13px",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderRightColor:e.palette.grey[100]},..."negative"===t&&{"&::before":{borderRightColor:"rgb(255, 204, 238) !important"}},..."positive"===t&&{"&::before":{borderRightColor:"rgb(153, 255, 153) !important"}}}})),Q=X("div")(({theme:e,annotationType:t})=>({width:"200px",overflow:"hidden",borderRadius:"4px",backgroundColor:"#ffffff",border:`4px solid ${e.palette.grey[100]}`,..."negative"===t&&{borderColor:"rgb(255, 204, 238) !important"},..."positive"===t&&{borderColor:"rgb(153, 255, 153) !important"}})),J=X("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),Z=X("div")(({theme:e,variant:t,annotationType:n})=>({flexGrow:1,width:"28%",textAlign:"center",padding:"4px",cursor:"pointer","&:not(:nth-child(3n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}},..."typeChange"===t&&"negative"===n&&{"&:hover":{backgroundColor:"rgb(153, 255, 153) !important"}},..."typeChange"===t&&"positive"===n&&{"&:hover":{backgroundColor:"rgb(255, 204, 238) !important"}}}));class ee extends U.Component{static __initStatic(){this.propTypes={anchorEl:V.object,open:V.bool,offset:V.number,value:V.string,type:V.string,onClose:V.func,onDelete:V.func,onSave:V.func,onTypeChange:V.func}}constructor(e){super(e),ee.prototype.__init.call(this),ee.prototype.__init2.call(this),ee.prototype.__init3.call(this),this.state={value:e.value}}UNSAFE_componentWillReceiveProps(e){const{value:t}=e,{value:n}=this.props;t!==n&&this.setState({value:t})}__init(){this.onValueChange=e=>this.setState({value:e.target.value})}__init2(){this.handleSave=()=>{const{value:e,onSave:t,onClose:n,onDelete:o}=this.props,{value:i}=this.state;""===i&&o(),e!==i&&t(e,i),this.setState({value:""}),n()}}__init3(){this.handleTypeChange=()=>{const{onTypeChange:e,onDelete:t}=this.props,{value:n}=this.state;""===n?t():e(n),this.setState({value:""})}}render(){const{anchorEl:e,offset:t,onDelete:n,open:o,type:i}=this.props,{value:a}=this.state;return U.createElement(Y,{anchorEl:e,elevation:2,open:o,onClose:this.handleSave,annotationType:i,style:{marginTop:`${t}px`,transition:"margin-top 2s ease-out"},transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"}},U.createElement(Q,{annotationType:i},U.createElement(G,{id:"annotation-editor",style:{padding:"2px 5px",width:"95%"},autoFocus:!0,multiline:!0,rows:1,maxRows:4,value:a,onChange:this.onValueChange,InputProps:{disableUnderline:!0}}),U.createElement(J,null,U.createElement(Z,{onClick:n},"Delete"),U.createElement(Z,{variant:"typeChange",annotationType:i,onClick:this.handleTypeChange},"negative"===i?"Green":"Pink"),U.createElement(Z,{onClick:this.handleSave},"Save"))))}}ee.__initStatic();const te=t,ne=n,{styled:oe}=i,{Popover:ie}=o,ae=oe(ie)({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginTop:"-16px","&::after":{position:"absolute",left:"calc(50% - 7px)",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderTopColor:"black"}}}),se=oe("div")(({theme:e})=>({width:"300px",overflow:"hidden",borderRadius:"4px",backgroundColor:e.palette.common.white,border:`2px solid ${e.palette.grey[100]}`})),re=oe("div")({display:"flex",flexWrap:"wrap"}),le=oe("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),de=oe("div")(({theme:e,variant:t})=>({width:"22%",textAlign:"center",padding:"4px",cursor:"pointer",borderBottom:`1px solid ${e.palette.grey[100]}`,"&:not(:nth-child(4n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:nth-child(4n)":{flexGrow:1},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}}}));class ce extends te.Component{static __initStatic(){this.propTypes={anchorEl:ne.object,open:ne.bool,annotations:ne.array,isNewAnnotation:ne.bool,onClose:ne.func,onDelete:ne.func,onEdit:ne.func,onWrite:ne.func,onAnnotate:ne.func}}render(){const{anchorEl:e,annotations:t,isNewAnnotation:n,onAnnotate:o,onClose:i,onEdit:a,onDelete:s,onWrite:r,open:l}=this.props;return te.createElement(ae,{anchorEl:e,open:l,onClose:i,elevation:5,transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}},te.createElement(se,null,te.createElement(re,null,t.map((e,t)=>te.createElement(de,{key:`annotation-${t}`,variant:e.type,onClick:()=>o(e)},e.label))),te.createElement(le,null,te.createElement(de,{onClick:i},"Cancel"),te.createElement(de,{style:{pointerEvents:"none"}}),n?te.createElement(te.Fragment,null,te.createElement(de,{variant:"positive",onClick:()=>r("positive")},"Write"),te.createElement(de,{variant:"negative",onClick:()=>r("negative")},"Write")):te.createElement(te.Fragment,null,te.createElement(de,{onClick:s},"Delete"),te.createElement(de,{onClick:a},"Edit")))))}}ce.__initStatic();const pe=t,{styled:he}=i,ue=n,me=l,{InputContainer:ge}=d,fe=he("div")({padding:"10px 120px 10px 16px",backgroundColor:"rgba(0, 0, 0, 0.06)",border:"1px solid #ccc",borderRadius:"4px",overflowY:"scroll",lineHeight:"36px",whiteSpace:"pre-wrap",overflowWrap:"break-word","& p":{margin:0},"& span[data-latex]":{userSelect:"none","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none"}}),be=he("div")({width:"230px"}),ye=he("div")({position:"relative",overflowX:"hidden",display:"flex"}),ve=he(ge)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2),marginTop:e.spacing(2),width:"100%"}));if(!document.getElementById("annotation-editor-styles")){const e=document.createElement("style");e.id="annotation-editor-styles",e.textContent='\n .sideAnnotation:before {\n position: absolute;\n right: var(--before-right, 100%);\n top: var(--before-top, 5px);\n border: solid transparent;\n content: "";\n height: 0;\n width: 0;\n pointer-events: none;\n border-width: var(--before-border-width, 7px);\n border-right-color: var(--before-border-color, rgb(153, 255, 153));\n }\n',document.head.appendChild(e)}class Ce extends pe.Component{static __initStatic(){this.propTypes={text:ue.string,comment:ue.string,annotations:ue.array,predefinedAnnotations:ue.array,onChange:ue.func.isRequired,onCommentChange:ue.func.isRequired,width:ue.number,height:ue.number,maxHeight:ue.string,disabled:ue.bool,disabledMath:ue.bool,customKeys:ue.array,keypadMode:ue.string}}constructor(e){super(e),Ce.prototype.__init.call(this),Ce.prototype.__init2.call(this),Ce.prototype.__init3.call(this),Ce.prototype.__init4.call(this),Ce.prototype.__init5.call(this),Ce.prototype.__init6.call(this),Ce.prototype.__init7.call(this),Ce.prototype.__init8.call(this),Ce.prototype.__init9.call(this),Ce.prototype.__init10.call(this),Ce.prototype.__init11.call(this),Ce.prototype.__init12.call(this),Ce.prototype.__init13.call(this),Ce.prototype.__init14.call(this),Ce.prototype.__init15.call(this),this.state={anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotation:null,annotationIndex:null}}componentDidMount(){const{annotations:e,text:t}=this.props;t&&e.forEach(e=>{const[t,n]=((e,t,n)=>{const o=j(n,t),i=[];let a=0;return o.forEach(n=>{const o=a+n.textContent.length;[e,t].forEach(e=>{a<=e&&e<o&&i.push({node:n,offset:e-a})}),a=o}),i})(e.start,e.end,this.textRef);if(t&&n){const o=document.createRange();o.setStart(t.node,t.offset),o.setEnd(n.node,n.offset);const i=$(o);this.createDOMAnnotation(i,e)}}),this.textRef&&(this.adjustAnnotationsPosition(),this.textRef.addEventListener("scroll",this.adjustAnnotationsPosition))}__init(){this.adjustAnnotationsPosition=()=>{if(this.textRef&&this.labelsRef){const e=this.textRef.offsetLeft+this.textRef.offsetWidth+8;Array.from(this.labelsRef.children).forEach(t=>{const n=B(t.dataset.annId),o=(n[0].offsetTop?n[0].offsetTop:n[0].offsetParent.offsetTop)-this.textRef.scrollTop-6;t.style.top=`${o}px`,t.style.left=`${e}px`})}}}__init2(){this.handleClick=e=>{const{annotations:t}=this.props,{selectionDetails:n}=this.state;if(n)return;const{id:o,annId:i}=e.target.dataset,a=o||i,s=B(a),r=K(a),l=t.findIndex(e=>e.id===a),d=r.hasAttribute("data-freeform");d&&(r.style.zIndex="10"),this.setState({anchorEl:s[0],openedMenu:!!o||!!i&&!d,openedEditor:!!i&&d,selectedElems:s,labelElem:r,annotationIndex:l,annotation:t[l],selectionDetails:null})}}__init3(){this.handleHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,i=B(o),a=K(o),s=a.hasAttribute("data-freeform");i.forEach(e=>{e.style.zIndex="20",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.7)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.55)")}),s?(a.style.zIndex="20",a.classList.contains("positive")?(a.style.backgroundColor="rgb(128, 255, 128)",a.style.setProperty("--before-border-color","rgb(153, 255, 153)")):a.classList.contains("negative")&&(a.style.backgroundColor="rgb(255, 179, 230)",a.style.setProperty("--before-border-color","rgb(255, 179, 230)"))):(a.style.zIndex="20",a.classList.contains("positive")?a.style.color="rgb(0, 77, 0)":a.classList.contains("negative")&&(a.style.color="rgb(153, 0, 102)"))}}__init4(){this.handleCancelHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,i=B(o),a=K(o),s=a.hasAttribute("data-freeform");i.forEach(e=>{e.style.zIndex="",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)")}),s?(a.style.zIndex="",a.classList.contains("positive")?(a.style.backgroundColor="rgb(153, 255, 153)",a.style.removeProperty("--before-border-color")):a.classList.contains("negative")&&(a.style.backgroundColor="rgb(255, 204, 238)",a.style.removeProperty("--before-border-color"))):(a.style.zIndex="",a.classList.contains("positive")?a.style.color="rgb(0, 128, 0)":a.classList.contains("negative")&&(a.style.color="rgb(204, 0, 136)"))}}__init5(){this.handleClose=e=>{const{selectedElems:t,labelElem:n}=this.state;t.length&&!t[0].hasAttribute("data-id")&&H(t,this.textRef),n&&(n.style.zIndex=""),this.setState({anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotationIndex:null,annotation:null}),z()}}__init6(){this.handleSelection=e=>{const t=window.getSelection();if(e.detail>2)z();else if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=e.toString(),o=this.textRef.contains(e.commonAncestorContainer);if(!t.isCollapsed&&""!==n&&o){const t=((e,t)=>{const n=document.createRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);const[,o]=O(n),[,i]=O(e),a=o.length;return{quote:i,start:a,end:a+i.length}})(e,this.textRef),n=$(e);this.setState({anchorEl:n[0],openedMenu:!0,selectedElems:n,selectionDetails:t})}}}}__init7(){this.deleteAnnotation=()=>{const{annotations:e,onChange:t}=this.props,{selectedElems:n,labelElem:o,annotationIndex:i,annotation:a}=this.state;(q(a.label)?this.labelsRef:n[0]).removeChild(o),H(n,this.textRef),e.splice(i,1),t(e),this.handleClose()}}__init8(){this.createDOMAnnotation=(e,t)=>{const{disabled:n}=this.props,{id:o,label:i,type:a}=t;(e||[]).forEach(e=>{e.dataset.id=o,e.className=`annotation ${a}`,e.style.position="relative",e.style.cursor="pointer","positive"===a?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":"negative"===a&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)"),e.onclick=!n&&this.handleClick,e.onmouseover=this.handleHover,e.onmouseout=this.handleCancelHover});const s=e&&e[0]||{},r=document.createElement("SPAN");if(r.dataset.annId=o,r.innerHTML=i,r.onclick=!n&&this.handleClick,r.onmouseover=this.handleHover,r.onmouseout=this.handleCancelHover,q(i)){const e=(s.offsetTop?s.offsetTop:s.offsetParent.offsetTop)-this.textRef.scrollTop,t=this.textRef.offsetLeft+this.textRef.offsetWidth+8;r.dataset.freeform=!0,r.className=`sideAnnotation ${a}`,r.style.position="absolute",r.style.padding="4px",r.style.borderRadius="4px",r.style.marginLeft="8px",r.style.width="180px",r.style.whiteSpace="pre-wrap",r.style.wordBreak="break-word",r.style.border="2px solid #ffffff",r.style.fontSize="14px",r.style.fontStyle="normal",r.style.fontWeight="normal",r.style.top=`${e}px`,r.style.left=`${t}px`,"negative"===a?r.style.backgroundColor="rgb(255, 204, 238)":"positive"===a&&(r.style.backgroundColor="rgb(153, 255, 153)"),r.style.setProperty("--before-border-width","7px"),r.style.setProperty("--before-top","5px"),r.style.setProperty("--before-right","100%"),"negative"===a?r.style.setProperty("--before-border-color","rgb(255, 204, 238)"):"positive"===a&&r.style.setProperty("--before-border-color","rgb(153, 255, 153)"),this.labelsRef.appendChild(r)}else r.className=`annotationLabel ${a}`,r.style.backgroundColor="rgb(242, 242, 242)",r.style.padding="2px",r.style.position="absolute",r.style.userSelect="none",r.style.whiteSpace="nowrap",r.style.top="-10px",r.style.left="-2px",r.style.fontSize="12px",r.style.fontStyle="normal",r.style.fontWeight="normal",r.style.lineHeight="6px",r.style.webkitUserSelect="none",r.style.mozUserSelect="none",r.style.msUserSelect="none","positive"===a?r.style.color="rgb(0, 128, 0)":"negative"===a&&(r.style.color="rgb(204, 0, 136)"),s.appendChild(r)}}__init9(){this.createNewAnnotation=(e,t)=>{const{selectedElems:n,selectionDetails:o}=this.state,i={id:[o.start,o.end,(new Date).getTime()].join("-"),label:e,type:t,...o};return this.createDOMAnnotation(n,i),i}}__init10(){this.handleMenuClick=e=>{const{annotations:t,onChange:n}=this.props,{annotation:o,annotationIndex:i}=this.state,{type:a,text:s}=e;if(o){const e={...o,label:s,type:a},{type:n,label:r}=o;this.updateLabel(r,e,a!==n&&n),t.splice(i,1,e)}else{const e=this.createNewAnnotation(s,a);t.push(e)}n(t),this.handleClose()}}__init11(){this.editAnnotation=()=>{this.setState({openedMenu:!1,openedEditor:!0})}}__init12(){this.addAnnotation=e=>{const{annotations:t,onChange:n}=this.props,o=this.createNewAnnotation("",e),i=K(o.id);t.push(o),this.setState({openedMenu:!1,openedEditor:!0,annotationIndex:t.length-1,annotation:o,labelElem:i}),n(t)}}__init13(){this.updateLabel=(e,t,n)=>{const{selectedElems:o,labelElem:i}=this.state,{label:a,type:s}=t;q(a)&&q(e)||!q(a)&&!q(e)?(i.innerHTML=a,n&&(i.classList.remove(n),i.classList.add(s),o.forEach(e=>{e.classList.remove(n),e.classList.add(s)}))):q(a)&&!q(e)?(o[0].removeChild(i),this.createDOMAnnotation(o,t)):!q(a)&&q(e)&&(this.labelsRef.removeChild(i),this.createDOMAnnotation(o,t))}}__init14(){this.changeAnnotationType=e=>{const{annotations:t,onChange:n}=this.props,{annotationIndex:o,selectedElems:i}=this.state,{type:a,label:s}=t[o],r="positive"===a?"negative":"positive",l={...t[o],type:r,label:e};i.forEach(e=>{e.classList.remove(a),e.classList.add(r)}),this.updateLabel(s,l,a),t.splice(o,1,l),n(t),this.handleClose()}}__init15(){this.updateAnnotation=(e,t)=>{const{annotations:n,onChange:o}=this.props,{annotationIndex:i}=this.state,a={...n[i],label:t};this.updateLabel(e,a),n.splice(i,1,a),o(n)}}componentWillUnmount(){this.textRef.removeEventListener("scroll",this.adjustAnnotationsPosition)}render(){const{comment:e,customKeys:t,disabled:n,disabledMath:o,keypadMode:i,height:a,width:s,maxHeight:r,onCommentChange:l,predefinedAnnotations:d,text:c}=this.props,{anchorEl:p,annotation:h,openedMenu:u,openedEditor:m,selectionDetails:g}=this.state,f=p&&(p.offsetTop?p.offsetTop:p.offsetParent.offsetTop),b=this.textRef&&f?f-this.textRef.scrollTop-8:0;return pe.createElement("div",null,pe.createElement(ye,null,pe.createElement(fe,{style:{width:s-34,minHeight:a,maxHeight:r},ref:e=>this.textRef=e,onMouseDown:n?()=>{}:z,onMouseUp:n?()=>{}:this.handleSelection,dangerouslySetInnerHTML:{__html:c}}),pe.createElement(be,{ref:e=>this.labelsRef=e})),pe.createElement(ve,{label:"Comment"},pe.createElement(me,{className:"prompt",markup:e||"",onChange:l,width:s&&(s+104).toString(),disabled:n,pluginProps:{math:{disabled:o,customKeys:t,keypadMode:i,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},textAlign:{disabled:!0}}})),pe.createElement(ce,{anchorEl:p,open:u&&!n,annotations:d,isNewAnnotation:!!g,onClose:this.handleClose,onDelete:this.deleteAnnotation,onEdit:this.editAnnotation,onWrite:this.addAnnotation,onAnnotate:this.handleMenuClick}),pe.createElement(ee,{anchorEl:this.textRef,open:m&&!n,offset:b,value:h&&h.label||"",type:h&&h.type,onClose:this.handleClose,onDelete:this.deleteAnnotation,onSave:this.updateAnnotation,onTypeChange:this.changeAnnotationType}))}}Ce.__initStatic();const xe=t,_e=n,Ee=a,{Typography:we}=o,{styled:Se}=i,{color:ke}=s,{Feedback:Ae}=s,{Collapsible:Re}=s,{PreviewPrompt:Te}=s,{UiLayout:Me}=s,Ie=l,Le=Ee("@pie-ui:extended-text-entry"),Pe=Se(Me)({backgroundColor:ke.background(),color:ke.text()}),Ne=Se(we)(({theme:e})=>({width:"100%",color:ke.text(),marginBottom:e.spacing(2),fontSize:"inherit"})),De=Se("div")(({theme:e})=>({marginBottom:e.spacing(2)})),je=Se(Ie)(({theme:e})=>({marginBottom:e.spacing(2),borderRadius:"4px"})),Oe=Se("h2")({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"});class We extends xe.Component{constructor(...e){super(...e),We.prototype.__init.call(this),We.prototype.__init2.call(this)}static __initStatic(){this.propTypes={onValueChange:_e.func.isRequired,onAnnotationsChange:_e.func.isRequired,onCommentChange:_e.func.isRequired,model:_e.object,session:_e.shape({value:_e.string,annotations:_e.array,comment:_e.string}).isRequired}}__init(){this.changeSessionValue=D(this.props.onValueChange,1500)}__init2(){this.changeSessionComment=D(this.props.onCommentChange,1500)}render(){const{model:e,session:t,onAnnotationsChange:n}=this.props,{animationsDisabled:o,annotatorMode:i,customKeys:a,dimensions:s,disabled:r,disabledAnnotator:l,equationEditor:d,extraCSSRules:c,feedback:p,mathInput:h,playersToolbarPosition:u,predefinedAnnotations:m,prompt:g,spanishInput:f,specialInput:b,spellCheckEnabled:y,teacherInstructions:v}=e,{annotations:C,comment:x,value:_}=t,{width:E,height:w}=s||{},S="40vh",k={position:"top"===u?"top":"bottom"};Le("[render] disabled? ",r);const A=xe.createElement(Te,{defaultClassName:"teacher-instructions",prompt:v}),R=[];return f&&R.push({language:"spanish"}),b&&R.push({language:"special"}),xe.createElement(Pe,{extraCSSRules:c,ref:e=>{this.containerRef=e}},xe.createElement(Oe,null,"Constructed Response Question"),v&&xe.createElement(De,null,o?A:xe.createElement(Re,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},A)),g&&xe.createElement(Ne,{component:"span"},xe.createElement(Te,{defaultClassName:"prompt",prompt:e.prompt})),i?xe.createElement(Ce,{text:_||"",annotations:C||[],comment:x||"",predefinedAnnotations:m||[],onChange:n,onCommentChange:this.changeSessionComment,width:E,height:w,maxHeight:S,disabled:l,disabledMath:!h,customKeys:a,keypadMode:d}):xe.createElement(je,{className:"response-area-editor",onChange:this.changeSessionValue,markup:_||"",maxWidth:E&&E.toString(),minWidth:"100px",minHeight:w&&w.toString(),maxHeight:S,disabled:r,highlightShape:!0,toolbarOpts:k,spellCheck:y,charactersLimit:5e4,autoWidthToolbar:!0,pluginProps:{math:{disabled:!h,customKeys:this.props.model.customKeys,keypadMode:this.props.model.equationEditor,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},table:{disabled:!0},textAlign:{disabled:!0},separateParagraphs:{disabled:!1},ul_list:{disabled:!0},ol_list:{disabled:!0}},languageCharactersProps:R}),p&&xe.createElement(Ae,{correctness:"correct",feedback:p}))}}We.__initStatic();const $e=t,He=a,{renderMath:ze}=r,qe=He("pie-element:extended-text-entry:print");class Be extends HTMLElement{constructor(){super(),this._options=null,this._model=null,this._session=[],this._root=null,this._rerender=D(()=>{if(this._model&&this._session){const e=((e,t)=>{const n="instructor"===t.role;return e.prompt=!1!==e.promptEnabled?e.prompt:void 0,e.teacherInstructions=n&&!1!==e.teacherInstructionsEnabled?e.teacherInstructions:void 0,e.showTeacherInstructions=n,e.mode=n?"evaluate":e.mode,e.dimensions={height:100,width:500,...e.dimensions},e.disabled=!0,e.feedback=void 0,e.animationsDisabled=!0,e})(this._model,this._options),t=this._options&&$e.createElement(We,{model:e,session:{},onChange:()=>{},onValueChange:()=>{},onAnnotationsChange:()=>{},onCommentChange:()=>{}});this._root||(this._root=c(this)),this._root.render(t),queueMicrotask(()=>{qe("render complete - render math"),ze(this)})}else qe("skip")},50,{leading:!1,trailing:!0})}set options(e){this._options=e}set model(e){this._model=e,this._rerender()}connectedCallback(){}disconnectedCallback(){this._root&&this._root.unmount()}}export{Be as default};
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@pie-element/extended-text-entry",
3
- "version": "14.0.0-next.42+bb1f3eb4e",
3
+ "repository": {
4
+ "type": "git",
5
+ "url": "https://github.com/pie-framework/pie-elements"
6
+ },
7
+ "version": "14.1.0-next.0+20d879b",
4
8
  "description": "",
5
- "repository": "pie-framework/pie-elements",
6
9
  "publishConfig": {
7
10
  "access": "public"
8
11
  },
@@ -14,21 +17,25 @@
14
17
  "@mui/icons-material": "^7.3.4",
15
18
  "@mui/material": "^7.3.4",
16
19
  "@pie-framework/pie-player-events": "^0.1.0",
17
- "@pie-lib/config-ui": "12.1.1-next.0",
18
- "@pie-lib/editable-html-tip-tap": "1.1.1-next.0",
19
- "@pie-lib/math-rendering": "4.1.1-next.0",
20
- "@pie-lib/render-ui": "5.1.1-next.0",
20
+ "@pie-lib/config-ui": "12.1.1-next.3",
21
+ "@pie-lib/editable-html-tip-tap": "1.1.1-next.3",
22
+ "@pie-lib/math-rendering": "4.1.1-next.1",
23
+ "@pie-lib/render-ui": "5.1.1-next.1",
21
24
  "classnames": "^2.2.5",
22
25
  "debug": "^4.1.1",
23
26
  "lodash.throttle": "^4.1.1",
24
27
  "prop-types": "^15.6.1",
25
- "react": "18.2.0",
26
- "react-dom": "18.2.0"
28
+ "react": "18.3.1",
29
+ "react-dom": "18.3.1"
27
30
  },
28
- "gitHead": "bb1f3eb4e3b5b1cb15024d459ffd6e94bf419712",
31
+ "gitHead": "20d879b8b8fa74decf5028d860d54cd09cbdf051",
29
32
  "scripts": {
30
33
  "postpublish": "../../scripts/postpublish"
31
34
  },
32
35
  "main": "lib/index.js",
33
- "module": "src/index.js"
36
+ "module": "src/index.js",
37
+ "exports": {
38
+ ".": "./src/index.js",
39
+ "./print": "./src/print.js"
40
+ }
34
41
  }