@pie-element/extended-text-entry 15.1.1-next.39 → 15.1.1-next.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configure/lib/index.js +4 -0
- package/configure/lib/index.js.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/module/configure.js +1 -1
- package/module/element.js +1 -1
- package/package.json +2 -2
package/configure/lib/index.js
CHANGED
|
@@ -102,9 +102,13 @@ class ExtendedTextEntry extends HTMLElement {
|
|
|
102
102
|
this._root.render(element);
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
|
+
connectedCallback() {
|
|
106
|
+
this.render();
|
|
107
|
+
}
|
|
105
108
|
disconnectedCallback() {
|
|
106
109
|
if (this._root) {
|
|
107
110
|
this._root.unmount();
|
|
111
|
+
this._root = null;
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_pieConfigureEvents","require","_react","_interopRequireDefault","_client","_main","_defaults","ExtendedTextEntry","HTMLElement","constructor","_root","_configuration","defaults","configuration","withRubric","forceEnabled","settings","_model","createDefaultModel","model","m","render","c","rubricEnabled","onModelChanged","dispatchEvent","ModelUpdatedEvent","onConfigurationChanged","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Main","bind","imageSupport","add","delete","uploadSoundSupport","createRoot","disconnectedCallback","unmount","exports","default","_defineProperty2","config","defaultModel"],"sources":["../src/index.js"],"sourcesContent":["import {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport Main from './main';\n\nimport defaults from './defaults';\n\nexport default class ExtendedTextEntry extends HTMLElement {\n static createDefaultModel = (model = {}, config) => {\n const defaultModel = { ...defaults.model, ...model };\n\n // if configuration.withRubric.forceEnabled is true, then we update the model (rubricEnabled)\n // without triggering the Model Updated event (for more details, check documentation)\n if (config?.withRubric?.forceEnabled && !defaultModel.rubricEnabled) {\n defaultModel.rubricEnabled = true;\n }\n\n return defaultModel;\n };\n\n constructor() {\n super();\n this._root = null;\n this._configuration = defaults.configuration;\n\n // if configuration.withRubric.forceEnabled is true, then we\n // update the configuration (we do not want to display the toggle in the Settings Panel)\n if (this._configuration.withRubric?.forceEnabled) {\n this._configuration.withRubric.settings = false;\n }\n\n this._model = ExtendedTextEntry.createDefaultModel({}, this._configuration);\n }\n\n set model(m) {\n this._model = ExtendedTextEntry.createDefaultModel(m, this._configuration);\n this.render();\n }\n\n set configuration(c) {\n this._configuration = {\n ...defaults.configuration,\n ...c,\n };\n\n const { withRubric = {} } = c || {};\n\n // if configuration.withRubric.forceEnabled is true, then we update the model (rubricEnabled)\n // without triggering the Model Updated event (for more details, check documentation)\n // and also update the configuration (we do not want to display the toggle in the Settings Panel)\n if (withRubric?.forceEnabled) {\n this._configuration.withRubric.settings = false;\n\n if (!this._model.rubricEnabled) {\n this._model.rubricEnabled = true;\n }\n }\n\n this.render();\n }\n\n onModelChanged(m) {\n this._model = m;\n this.render();\n this.dispatchEvent(new ModelUpdatedEvent(this._model, false));\n }\n\n onConfigurationChanged(c) {\n this._configuration = {\n ...defaults.configuration,\n ...c,\n };\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this.render();\n }\n\n /**\n *\n * @param {done, progress, file} handler\n */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n render() {\n if (this._model) {\n const element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged.bind(this),\n onConfigurationChanged: this.onConfigurationChanged.bind(this),\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,SAAA,GAAAH,sBAAA,CAAAF,OAAA;AAEe,MAAMM,iBAAiB,SAASC,WAAW,CAAC;EAazDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAG,IAAI;IACjB,IAAI,CAACC,cAAc,GAAGC,iBAAQ,CAACC,aAAa;;IAE5C;IACA;IACA,IAAI,IAAI,CAACF,cAAc,CAACG,UAAU,EAAEC,YAAY,EAAE;MAChD,IAAI,CAACJ,cAAc,CAACG,UAAU,CAACE,QAAQ,GAAG,KAAK;IACjD;IAEA,IAAI,CAACC,MAAM,GAAGV,iBAAiB,CAACW,kBAAkB,CAAC,CAAC,CAAC,EAAE,IAAI,CAACP,cAAc,CAAC;EAC7E;EAEA,IAAIQ,KAAKA,CAACC,CAAC,EAAE;IACX,IAAI,CAACH,MAAM,GAAGV,iBAAiB,CAACW,kBAAkB,CAACE,CAAC,EAAE,IAAI,CAACT,cAAc,CAAC;IAC1E,IAAI,CAACU,MAAM,CAAC,CAAC;EACf;EAEA,IAAIR,aAAaA,CAACS,CAAC,EAAE;IACnB,IAAI,CAACX,cAAc,GAAG;MACpB,GAAGC,iBAAQ,CAACC,aAAa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,CAACL,GAAG,EAAEC,IAAI,EAAE;IACvB,IAAI,CAACR,aAAa,CAAC,IAAIa,oCAAgB,CAACN,GAAG,EAAEC,IAAI,CAAC,CAAC;EACrD;EAEAZ,MAAMA,CAAA,EAAG;IACP,IAAI,IAAI,CAACJ,MAAM,EAAE;MACf,MAAMsB,OAAO,gBAAGC,cAAK,CAACC,aAAa,CAACC,aAAI,EAAE;QACxCvB,KAAK,EAAE,IAAI,CAACF,MAAM;QAClBJ,aAAa,EAAE,IAAI,CAACF,cAAc;QAClCa,cAAc,EAAE,IAAI,CAACA,cAAc,CAACmB,IAAI,CAAC,IAAI,CAAC;QAC9ChB,sBAAsB,EAAE,IAAI,CAACA,sBAAsB,CAACgB,IAAI,CAAC,IAAI,CAAC;QAC9DC,YAAY,EAAE;UACZC,GAAG,EAAE,IAAI,CAACjB,WAAW,CAACe,IAAI,CAAC,IAAI,CAAC;UAChCG,MAAM,EAAE,IAAI,CAACf,aAAa,CAACY,IAAI,CAAC,IAAI;QACtC,CAAC;QACDI,kBAAkB,EAAE;UAClBF,GAAG,EAAE,IAAI,CAACV,WAAW,CAACQ,IAAI,CAAC,IAAI,CAAC;UAChCG,MAAM,EAAE,IAAI,CAACT,aAAa,CAACM,IAAI,CAAC,IAAI;QACtC;MACF,CAAC,CAAC;MAEF,IAAI,CAAC,IAAI,CAACjC,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAAsC,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAACtC,KAAK,CAACW,MAAM,CAACkB,OAAO,CAAC;IAC5B;EACF;EAEAU,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"index.js","names":["_pieConfigureEvents","require","_react","_interopRequireDefault","_client","_main","_defaults","ExtendedTextEntry","HTMLElement","constructor","_root","_configuration","defaults","configuration","withRubric","forceEnabled","settings","_model","createDefaultModel","model","m","render","c","rubricEnabled","onModelChanged","dispatchEvent","ModelUpdatedEvent","onConfigurationChanged","insertImage","handler","InsertImageEvent","onDeleteImage","src","done","DeleteImageEvent","insertSound","InsertSoundEvent","onDeleteSound","DeleteSoundEvent","element","React","createElement","Main","bind","imageSupport","add","delete","uploadSoundSupport","createRoot","connectedCallback","disconnectedCallback","unmount","exports","default","_defineProperty2","config","defaultModel"],"sources":["../src/index.js"],"sourcesContent":["import {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport Main from './main';\n\nimport defaults from './defaults';\n\nexport default class ExtendedTextEntry extends HTMLElement {\n static createDefaultModel = (model = {}, config) => {\n const defaultModel = { ...defaults.model, ...model };\n\n // if configuration.withRubric.forceEnabled is true, then we update the model (rubricEnabled)\n // without triggering the Model Updated event (for more details, check documentation)\n if (config?.withRubric?.forceEnabled && !defaultModel.rubricEnabled) {\n defaultModel.rubricEnabled = true;\n }\n\n return defaultModel;\n };\n\n constructor() {\n super();\n this._root = null;\n this._configuration = defaults.configuration;\n\n // if configuration.withRubric.forceEnabled is true, then we\n // update the configuration (we do not want to display the toggle in the Settings Panel)\n if (this._configuration.withRubric?.forceEnabled) {\n this._configuration.withRubric.settings = false;\n }\n\n this._model = ExtendedTextEntry.createDefaultModel({}, this._configuration);\n }\n\n set model(m) {\n this._model = ExtendedTextEntry.createDefaultModel(m, this._configuration);\n this.render();\n }\n\n set configuration(c) {\n this._configuration = {\n ...defaults.configuration,\n ...c,\n };\n\n const { withRubric = {} } = c || {};\n\n // if configuration.withRubric.forceEnabled is true, then we update the model (rubricEnabled)\n // without triggering the Model Updated event (for more details, check documentation)\n // and also update the configuration (we do not want to display the toggle in the Settings Panel)\n if (withRubric?.forceEnabled) {\n this._configuration.withRubric.settings = false;\n\n if (!this._model.rubricEnabled) {\n this._model.rubricEnabled = true;\n }\n }\n\n this.render();\n }\n\n onModelChanged(m) {\n this._model = m;\n this.render();\n this.dispatchEvent(new ModelUpdatedEvent(this._model, false));\n }\n\n onConfigurationChanged(c) {\n this._configuration = {\n ...defaults.configuration,\n ...c,\n };\n\n if (this._model) {\n this.onModelChanged(this._model);\n }\n\n this.render();\n }\n\n /**\n *\n * @param {done, progress, file} handler\n */\n insertImage(handler) {\n this.dispatchEvent(new InsertImageEvent(handler));\n }\n\n onDeleteImage(src, done) {\n this.dispatchEvent(new DeleteImageEvent(src, done));\n }\n\n insertSound(handler) {\n this.dispatchEvent(new InsertSoundEvent(handler));\n }\n\n onDeleteSound(src, done) {\n this.dispatchEvent(new DeleteSoundEvent(src, done));\n }\n\n render() {\n if (this._model) {\n const element = React.createElement(Main, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged.bind(this),\n onConfigurationChanged: this.onConfigurationChanged.bind(this),\n imageSupport: {\n add: this.insertImage.bind(this),\n delete: this.onDeleteImage.bind(this),\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(element);\n }\n }\n\n connectedCallback() {\n this.render();\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,mBAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAF,sBAAA,CAAAF,OAAA;AAEA,IAAAK,SAAA,GAAAH,sBAAA,CAAAF,OAAA;AAEe,MAAMM,iBAAiB,SAASC,WAAW,CAAC;EAazDC,WAAWA,CAAA,EAAG;IACZ,KAAK,CAAC,CAAC;IACP,IAAI,CAACC,KAAK,GAAG,IAAI;IACjB,IAAI,CAACC,cAAc,GAAGC,iBAAQ,CAACC,aAAa;;IAE5C;IACA;IACA,IAAI,IAAI,CAACF,cAAc,CAAC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ACT,aAAa,CAACM,IAAI,CAAC,IAAI;QACtC;MACF,CAAC,CAAC;MAEF,IAAI,CAAC,IAAI,CAACjC,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAAsC,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAACtC,KAAK,CAACW,MAAM,CAACkB,OAAO,CAAC;IAC5B;EACF;EAEAU,iBAAiBA,CAAA,EAAG;IAClB,IAAI,CAAC5B,MAAM,CAAC,CAAC;EACf;EAEA6B,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACxC,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACyC,OAAO,CAAC,CAAC;MACpB,IAAI,CAACzC,KAAK,GAAG,IAAI;IACnB;EACF;AACF;AAAC0C,OAAA,CAAAC,OAAA,GAAA9C,iBAAA;AAAA,IAAA+C,gBAAA,CAAAD,OAAA,EA/HoB9C,iBAAiB,wBACR,CAACY,KAAK,GAAG,CAAC,CAAC,EAAEoC,MAAM,KAAK;EAClD,MAAMC,YAAY,GAAG;IAAE,GAAG5C,iBAAQ,CAACO,KAAK;IAAE,GAAGA;EAAM,CAAC;;EAEpD;EACA;EACA,IAAIoC,MAAM,EAAEzC,UAAU,EAAEC,YAAY,IAAI,CAACyC,YAAY,CAACjC,aAAa,EAAE;IACnEiC,YAAY,CAACjC,aAAa,GAAG,IAAI;EACnC;EAEA,OAAOiC,YAAY;AACrB,CAAC","ignoreList":[]}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_main","_interopRequireDefault","require","_react","_client","_debug","_mathRendering","_piePlayerEvents","log","debug","domParser","window","undefined","DOMParser","parseFromString","v","textContent","value","document","body","err","isComplete","tc","out","length","RootExtendedTextEntry","HTMLElement","constructor","_model","_session","_root","setLangAttribute","language","lang","slice","setAttribute","model","m","dispatchEvent","ModelSetEvent","tagName","toLowerCase","render","session","s","valueChange","SessionChangedEvent","annotationsChange","annotations","commentChange","comment","connectedCallback","elem","React","createElement","Main","onValueChange","bind","onAnnotationsChange","onCommentChange","createRoot","queueMicrotask","renderMath","disconnectedCallback","unmount","exports","default"],"sources":["../src/index.js"],"sourcesContent":["import Main from './main';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\n\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\n\nconst log = debug('@pie-elements:extended-text-entry');\n\nconst domParser = typeof window !== undefined ? new DOMParser() : { parseFromString: (v) => v };\n\nexport function textContent(value) {\n if (typeof value !== 'string') {\n return undefined;\n }\n\n try {\n const document = domParser.parseFromString(value, 'text/html');\n const textContent = document.body.textContent;\n\n return textContent;\n } catch (err) {\n log('tried to parse as dom and failed', value);\n return value;\n }\n}\n\nexport function isComplete(value) {\n const tc = textContent(value);\n const out = tc !== undefined && tc.length > 0;\n\n return out;\n}\n\nexport default class RootExtendedTextEntry extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._root = null;\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), false, !!this._model));\n\n this.render();\n }\n\n set session(s) {\n this._session = s;\n this.render();\n }\n\n get session() {\n return this._session;\n }\n\n valueChange(value) {\n this._session.value = value;\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(value)));\n\n this.render();\n }\n\n annotationsChange(annotations) {\n this._session.annotations = annotations;\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), true));\n\n this.render();\n }\n\n commentChange(comment) {\n this._session.comment = comment;\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(comment)));\n\n this.render();\n }\n\n connectedCallback() {\n this.setAttribute('aria-label', 'Written Response Question');\n this.setAttribute('role', 'region');\n\n this.render();\n }\n\n render() {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onValueChange: this.valueChange.bind(this),\n onAnnotationsChange: this.annotationsChange.bind(this),\n onCommentChange: this.commentChange.bind(this),\n });\n\n this.setLangAttribute();\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(elem);\n queueMicrotask(() => {\n renderMath(this);\n });\n }\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAJ,sBAAA,CAAAC,OAAA;AAEA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AAEA,MAAMM,GAAG,GAAG,IAAAC,cAAK,EAAC,mCAAmC,CAAC;AAEtD,MAAMC,SAAS,GAAG,OAAOC,MAAM,KAAKC,SAAS,GAAG,IAAIC,SAAS,CAAC,CAAC,GAAG;EAAEC,eAAe,EAAGC,CAAC,IAAKA;AAAE,CAAC;AAExF,SAASC,WAAWA,CAACC,KAAK,EAAE;EACjC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAOL,SAAS;EAClB;EAEA,IAAI;IACF,MAAMM,QAAQ,GAAGR,SAAS,CAACI,eAAe,CAACG,KAAK,EAAE,WAAW,CAAC;IAC9D,MAAMD,WAAW,GAAGE,QAAQ,CAACC,IAAI,CAACH,WAAW;IAE7C,OAAOA,WAAW;EACpB,CAAC,CAAC,OAAOI,GAAG,EAAE;IACZZ,GAAG,CAAC,kCAAkC,EAAES,KAAK,CAAC;IAC9C,OAAOA,KAAK;EACd;AACF;AAEO,SAASI,UAAUA,CAACJ,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AE,IAAI,CAACX,iBAAiB,CAACU,IAAI,CAAC,IAAI,CAAC;QACtDE,eAAe,EAAE,IAAI,CAACV,aAAa,CAACQ,IAAI,CAAC,IAAI;MAC/C,CAAC,CAAC;MAEF,IAAI,CAAC1B,gBAAgB,CAAC,CAAC;MAEvB,IAAI,CAAC,IAAI,CAACD,KAAK,EAAE;QACf,IAAI,CAACA,KAAK,GAAG,IAAA8B,kBAAU,EAAC,IAAI,CAAC;MAC/B;MACA,IAAI,CAAC9B,KAAK,CAACY,MAAM,CAACU,IAAI,CAAC;MACvBS,cAAc,CAAC,MAAM;QACnB,IAAAC,yBAAU,EAAC,IAAI,CAAC;MAClB,CAAC,CAAC;IACJ;EACF;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACjC,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACkC,OAAO,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","names":["_main","_interopRequireDefault","require","_react","_client","_debug","_mathRendering","_piePlayerEvents","log","debug","domParser","window","undefined","DOMParser","parseFromString","v","textContent","value","document","body","err","isComplete","tc","out","length","RootExtendedTextEntry","HTMLElement","constructor","_model","_session","_root","setLangAttribute","language","lang","slice","setAttribute","model","m","dispatchEvent","ModelSetEvent","tagName","toLowerCase","render","session","s","valueChange","SessionChangedEvent","annotationsChange","annotations","commentChange","comment","connectedCallback","elem","React","createElement","Main","onValueChange","bind","onAnnotationsChange","onCommentChange","createRoot","queueMicrotask","renderMath","disconnectedCallback","unmount","exports","default"],"sources":["../src/index.js"],"sourcesContent":["import Main from './main';\nimport React from 'react';\nimport { createRoot } from 'react-dom/client';\nimport debug from 'debug';\n\nimport { renderMath } from '@pie-lib/math-rendering';\nimport { ModelSetEvent, SessionChangedEvent } from '@pie-framework/pie-player-events';\n\nconst log = debug('@pie-elements:extended-text-entry');\n\nconst domParser = typeof window !== undefined ? new DOMParser() : { parseFromString: (v) => v };\n\nexport function textContent(value) {\n if (typeof value !== 'string') {\n return undefined;\n }\n\n try {\n const document = domParser.parseFromString(value, 'text/html');\n const textContent = document.body.textContent;\n\n return textContent;\n } catch (err) {\n log('tried to parse as dom and failed', value);\n return value;\n }\n}\n\nexport function isComplete(value) {\n const tc = textContent(value);\n const out = tc !== undefined && tc.length > 0;\n\n return out;\n}\n\nexport default class RootExtendedTextEntry extends HTMLElement {\n constructor() {\n super();\n this._model = null;\n this._session = null;\n this._root = null;\n }\n\n setLangAttribute() {\n const language = this._model && typeof this._model.language ? this._model.language : '';\n const lang = language ? language.slice(0, 2) : 'en';\n this.setAttribute('lang', lang);\n }\n\n set model(m) {\n this._model = m;\n this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), false, !!this._model));\n\n this.render();\n }\n\n set session(s) {\n this._session = s;\n this.render();\n }\n\n get session() {\n return this._session;\n }\n\n valueChange(value) {\n this._session.value = value;\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(value)));\n\n this.render();\n }\n\n annotationsChange(annotations) {\n this._session.annotations = annotations;\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), true));\n\n this.render();\n }\n\n commentChange(comment) {\n this._session.comment = comment;\n\n this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), isComplete(comment)));\n\n this.render();\n }\n\n connectedCallback() {\n this.setAttribute('aria-label', 'Written Response Question');\n this.setAttribute('role', 'region');\n\n this.render();\n }\n\n render() {\n if (this._model && this._session) {\n let elem = React.createElement(Main, {\n model: this._model,\n session: this._session,\n onValueChange: this.valueChange.bind(this),\n onAnnotationsChange: this.annotationsChange.bind(this),\n onCommentChange: this.commentChange.bind(this),\n });\n\n this.setLangAttribute();\n\n if (!this._root) {\n this._root = createRoot(this);\n }\n this._root.render(elem);\n queueMicrotask(() => {\n renderMath(this);\n });\n }\n }\n\n disconnectedCallback() {\n if (this._root) {\n this._root.unmount();\n this._root = null;\n }\n }\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAA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CAAC;MAClB,CAAC,CAAC;IACJ;EACF;EAEAC,oBAAoBA,CAAA,EAAG;IACrB,IAAI,IAAI,CAACjC,KAAK,EAAE;MACd,IAAI,CAACA,KAAK,CAACkC,OAAO,CAAC,CAAC;MACpB,IAAI,CAAClC,KAAK,GAAG,IAAI;IACnB;EACF;AACF;AAACmC,OAAA,CAAAC,OAAA,GAAAzC,qBAAA","ignoreList":[]}
|
package/module/configure.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_dll_react as e,_dll_prop_types as t,_dll_mui__material as n,_dll_mui__material_styles as i,_dll_react_dom_client as a}from"../../../@pie-lib/shared-module@^5.2.6/module/index.js";import{_dll_pie_lib__config_ui as s}from"../../../@pie-lib/config-module@^4.0.11/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as o}from"../../../@pie-lib/editable-html-module@^7.1.8/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 _=l.InsertSoundEvent=m;const E=e,f=t,{Typography:C}=n,{styled:I}=i,{FeedbackSelector:v}=s,{InputContainer:S}=s,{settings:x}=s,{layout:y}=s,k=o,{ALL_PLUGINS:P}=o;function w(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:M,toggle:T,numberFields:A,dropdown:D}=x,R={type:"default",default:"Your answer has been submitted"},q=I(C)(({theme:e})=>({paddingBottom:e.spacing(1)})),Y=I(S)(({theme:e})=>({paddingTop:e.spacing(1),marginTop:e.spacing(2),marginBottom:e.spacing(2),width:"100%"})),O=I("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)}));class j extends E.Component{static __initStatic(){this.propTypes={onModelChanged:f.func.isRequired,onConfigurationChanged:f.func,model:f.object.isRequired,configuration:f.object.isRequired,imageSupport:f.object.isRequired,uploadSoundSupport:f.object.isRequired}}constructor(e){super(e),j.prototype.__init.call(this),j.prototype.__init2.call(this),j.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:f={},mathInput:C={},maxImageWidth:I={},maxImageHeight:S={},multiple:x={},withRubric:j={},mathMlOptions:H={},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=S&&S.prompt,X={position:"top"===U?"top":"bottom"},Z={mathInput:C.settings&&T(C.label),equationEditor:d.enabled&&e.mathInput&&D(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&&T(g.label),specialInput:b.settings&&T(b.label),dimensions:r.settings&&A(r.label,{width:{label:"Width (px)",suffix:"px",min:100,max:1200},height:{label:"Height (px)",suffix:"px",min:100,max:500}}),"multiple.enabled":x.settings&&T(x.label,!0),promptEnabled:u.settings&&T(u.label),feedbackEnabled:c.settings&&T(c.label),annotationsEnabled:o.settings&&T(o.label),spellCheckEnabled:m.settings&&T(m.label),playerSpellCheckDisabled:p.settings&&T(p.label)},$={teacherInstructionsEnabled:f.settings&&T(f.label),studentInstructionsEnabled:_.settings&&T(_.label),rubricEnabled:w([j,"optionalAccess",e=>e.settings])&&T(w([j,"optionalAccess",e=>e.label]))},ee=e=>Object.assign({...F},e||{});return E.createElement(y.ConfigLayout,{extraCSSRules:W,dimensions:l,hideSettings:h,settings:E.createElement(M,{model:e,configuration:t,onChangeModel:e=>a(e),onChangeConfiguration:e=>i(e),groups:{Settings:Z,Properties:$}})},B&&E.createElement(Y,{label:f.label},E.createElement(k,{className:"prompt",markup:e.teacherInstructions||"",onChange:this.changeTeacherInstructions,imageSupport:n,nonEmpty:!1,error:K,toolbarOpts:X,spellCheck:N,maxImageWidth:I&&I.teacherInstructions||Q,maxImageHeight:S&&S.teacherInstructions||V,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:H,pluginProps:ee(w([f,"optionalAccess",e=>e.inputConfiguration]))}),K&&E.createElement(O,null,K)),z&&E.createElement(Y,{label:u.label},E.createElement(k,{activePlugins:P,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:H,pluginProps:ee(w([u,"optionalAccess",e=>e.inputConfiguration]))}),J&&E.createElement(O,null,J)),L&&E.createElement(E.Fragment,null,E.createElement(q,{variant:"h6"},"Feedback"),E.createElement(v,{label:"When submitted, show",feedback:e.feedback||R,onChange:this.changeFeedback,toolbarOpts:X})))}}j.__initStatic();var H={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"},F={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 G=e,{createRoot:W}=a;function L(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 z extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={},t)=>{const n={...H,...e};return L([t,"optionalAccess",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&!n.rubricEnabled&&(n.rubricEnabled=!0),n}}constructor(){super(),this._root=null,this._configuration=F,L([this,"access",e=>e._configuration,"access",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1),this._model=z.createDefaultModel({},this._configuration)}set model(e){this._model=z.createDefaultModel(e,this._configuration),this.render()}set configuration(e){this._configuration={...F,...e};const{withRubric:t={}}=e||{};L([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={...F,...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))}onDeleteSound(e,t){this.dispatchEvent(new b(e,t))}render(){if(this._model){const e=G.createElement(j,{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=W(this)),this._root.render(e)}}disconnectedCallback(){this._root&&this._root.unmount()}}z.__initStatic();export{z as default};
|
|
1
|
+
import{_dll_react as e,_dll_prop_types as t,_dll_mui__material as n,_dll_mui__material_styles as i,_dll_react_dom_client as a}from"../../../@pie-lib/shared-module@^5.2.6/module/index.js";import{_dll_pie_lib__config_ui as s}from"../../../@pie-lib/config-module@^4.0.11/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as o}from"../../../@pie-lib/editable-html-module@^7.1.8/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 _=l.InsertSoundEvent=m;const E=e,f=t,{Typography:C}=n,{styled:I}=i,{FeedbackSelector:v}=s,{InputContainer:S}=s,{settings:x}=s,{layout:y}=s,k=o,{ALL_PLUGINS:P}=o;function w(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:M,toggle:T,numberFields:A,dropdown:D}=x,R={type:"default",default:"Your answer has been submitted"},q=I(C)(({theme:e})=>({paddingBottom:e.spacing(1)})),Y=I(S)(({theme:e})=>({paddingTop:e.spacing(1),marginTop:e.spacing(2),marginBottom:e.spacing(2),width:"100%"})),O=I("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)}));class j extends E.Component{static __initStatic(){this.propTypes={onModelChanged:f.func.isRequired,onConfigurationChanged:f.func,model:f.object.isRequired,configuration:f.object.isRequired,imageSupport:f.object.isRequired,uploadSoundSupport:f.object.isRequired}}constructor(e){super(e),j.prototype.__init.call(this),j.prototype.__init2.call(this),j.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:f={},mathInput:C={},maxImageWidth:I={},maxImageHeight:S={},multiple:x={},withRubric:j={},mathMlOptions:H={},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=S&&S.prompt,X={position:"top"===U?"top":"bottom"},Z={mathInput:C.settings&&T(C.label),equationEditor:d.enabled&&e.mathInput&&D(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&&T(g.label),specialInput:b.settings&&T(b.label),dimensions:r.settings&&A(r.label,{width:{label:"Width (px)",suffix:"px",min:100,max:1200},height:{label:"Height (px)",suffix:"px",min:100,max:500}}),"multiple.enabled":x.settings&&T(x.label,!0),promptEnabled:u.settings&&T(u.label),feedbackEnabled:c.settings&&T(c.label),annotationsEnabled:o.settings&&T(o.label),spellCheckEnabled:m.settings&&T(m.label),playerSpellCheckDisabled:p.settings&&T(p.label)},$={teacherInstructionsEnabled:f.settings&&T(f.label),studentInstructionsEnabled:_.settings&&T(_.label),rubricEnabled:w([j,"optionalAccess",e=>e.settings])&&T(w([j,"optionalAccess",e=>e.label]))},ee=e=>Object.assign({...F},e||{});return E.createElement(y.ConfigLayout,{extraCSSRules:W,dimensions:l,hideSettings:h,settings:E.createElement(M,{model:e,configuration:t,onChangeModel:e=>a(e),onChangeConfiguration:e=>i(e),groups:{Settings:Z,Properties:$}})},B&&E.createElement(Y,{label:f.label},E.createElement(k,{className:"prompt",markup:e.teacherInstructions||"",onChange:this.changeTeacherInstructions,imageSupport:n,nonEmpty:!1,error:K,toolbarOpts:X,spellCheck:N,maxImageWidth:I&&I.teacherInstructions||Q,maxImageHeight:S&&S.teacherInstructions||V,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:H,pluginProps:ee(w([f,"optionalAccess",e=>e.inputConfiguration]))}),K&&E.createElement(O,null,K)),z&&E.createElement(Y,{label:u.label},E.createElement(k,{activePlugins:P,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:H,pluginProps:ee(w([u,"optionalAccess",e=>e.inputConfiguration]))}),J&&E.createElement(O,null,J)),L&&E.createElement(E.Fragment,null,E.createElement(q,{variant:"h6"},"Feedback"),E.createElement(v,{label:"When submitted, show",feedback:e.feedback||R,onChange:this.changeFeedback,toolbarOpts:X})))}}j.__initStatic();var H={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"},F={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 G=e,{createRoot:W}=a;function L(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 z extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={},t)=>{const n={...H,...e};return L([t,"optionalAccess",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&!n.rubricEnabled&&(n.rubricEnabled=!0),n}}constructor(){super(),this._root=null,this._configuration=F,L([this,"access",e=>e._configuration,"access",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1),this._model=z.createDefaultModel({},this._configuration)}set model(e){this._model=z.createDefaultModel(e,this._configuration),this.render()}set configuration(e){this._configuration={...F,...e};const{withRubric:t={}}=e||{};L([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={...F,...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))}onDeleteSound(e,t){this.dispatchEvent(new b(e,t))}render(){if(this._model){const e=G.createElement(j,{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=W(this)),this._root.render(e)}}connectedCallback(){this.render()}disconnectedCallback(){this._root&&(this._root.unmount(),this._root=null)}}z.__initStatic();export{z as default};
|
package/module/element.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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_client as a}from"../../../@pie-lib/shared-module@^5.2.6/module/index.js";import{_dll_pie_lib__math_rendering as r}from"../../../@pie-lib/math-rendering-module@^5.0.11/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^7.1.8/module/index.js";import{_dll_pie_lib__config_ui as d}from"../../../@pie-lib/config-module@^4.0.11/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},h3:{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},h3:{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={};Object.defineProperty(Oe,"__esModule",{value:!0});class We extends CustomEvent{constructor(e,t,n){super(We.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}We.TYPE="model-set";var $e=Oe.ModelSetEvent=We;class He extends CustomEvent{constructor(e,t){super(He.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}He.TYPE="session-changed";var ze=Oe.SessionChangedEvent=He;const qe=e,{createRoot:Be}=a,Fe=i,{renderMath:Ke}=r,Ue=Fe("@pie-elements:extended-text-entry"),Ve=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function Ye(e){if("string"==typeof e)try{const t=Ve.parseFromString(e,"text/html");return t.body.textContent}catch(t){return Ue("tried to parse as dom and failed",e),e}}function Ge(e){const t=Ye(e);return void 0!==t&&t.length>0}class Xe 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 $e(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(),Ge(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(),Ge(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=qe.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=Be(this)),this._root.render(e),queueMicrotask(()=>{Ke(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{Xe as default,Ge as isComplete,Ye 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_client as a}from"../../../@pie-lib/shared-module@^5.2.6/module/index.js";import{_dll_pie_lib__math_rendering as r}from"../../../@pie-lib/math-rendering-module@^5.0.11/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^7.1.8/module/index.js";import{_dll_pie_lib__config_ui as d}from"../../../@pie-lib/config-module@^4.0.11/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},h3:{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},h3:{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={};Object.defineProperty(Oe,"__esModule",{value:!0});class We extends CustomEvent{constructor(e,t,n){super(We.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}We.TYPE="model-set";var $e=Oe.ModelSetEvent=We;class He extends CustomEvent{constructor(e,t){super(He.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}He.TYPE="session-changed";var ze=Oe.SessionChangedEvent=He;const qe=e,{createRoot:Be}=a,Fe=i,{renderMath:Ke}=r,Ue=Fe("@pie-elements:extended-text-entry"),Ve=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function Ye(e){if("string"==typeof e)try{const t=Ve.parseFromString(e,"text/html");return t.body.textContent}catch(t){return Ue("tried to parse as dom and failed",e),e}}function Ge(e){const t=Ye(e);return void 0!==t&&t.length>0}class Xe 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 $e(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(),Ge(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(),Ge(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=qe.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=Be(this)),this._root.render(e),queueMicrotask(()=>{Ke(this)})}}disconnectedCallback(){this._root&&(this._root.unmount(),this._root=null)}}export{Xe as default,Ge as isComplete,Ye as textContent};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/extended-text-entry",
|
|
3
3
|
"repository": "pie-framework/pie-elements",
|
|
4
|
-
"version": "15.1.1-next.
|
|
4
|
+
"version": "15.1.1-next.46+59d45d73a",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react": "18.3.1",
|
|
26
26
|
"react-dom": "18.3.1"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "59d45d73a09323319b2ff8842450db900e85e7c6",
|
|
29
29
|
"scripts": {
|
|
30
30
|
"postpublish": "../../scripts/postpublish"
|
|
31
31
|
},
|