@pie-element/extended-text-entry 14.0.0-beta.1 → 14.0.0-next.42
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/package.json +2 -2
- package/controller/package.json +1 -1
- package/module/configure.js +1 -0
- package/module/controller.js +139 -0
- package/module/demo.js +38 -0
- package/module/element.js +1 -0
- package/module/index.html +21 -0
- package/module/manifest.json +22 -0
- package/module/print-demo.js +76 -0
- package/module/print.html +18 -0
- package/package.json +6 -6
package/configure/package.json
CHANGED
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"@mui/icons-material": "^7.3.4",
|
|
14
14
|
"@mui/material": "^7.3.4",
|
|
15
15
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
16
|
-
"@pie-lib/config-ui": "12.1.
|
|
17
|
-
"@pie-lib/editable-html-tip-tap": "1.1.
|
|
16
|
+
"@pie-lib/config-ui": "12.1.1-next.0",
|
|
17
|
+
"@pie-lib/editable-html-tip-tap": "1.1.1-next.0",
|
|
18
18
|
"lodash": "^4.17.15",
|
|
19
19
|
"prop-types": "^15.6.2",
|
|
20
20
|
"react": "18.2.0",
|
package/controller/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_dll_react_dom as e,_dll_react as t,_dll_prop_types as n,_dll_mui__material as i,_dll_mui__material_styles as a}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";import{_dll_pie_lib__config_ui as s}from"../../../@pie-lib/config-module@^3.0.0/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as o}from"../../../@pie-lib/editable-html-module@^6.0.5/module/index.js";var l={};Object.defineProperty(l,"__esModule",{value:!0});class r extends CustomEvent{constructor(e,t=!1){super(r.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}r.TYPE="model.updated";var d=l.ModelUpdatedEvent=r;class c extends CustomEvent{constructor(e,t){super(c.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}c.TYPE="delete.image";var p=l.DeleteImageEvent=c;class u extends CustomEvent{constructor(e){super(u.TYPE,{bubbles:!0,detail:e}),this.handler=e}}u.TYPE="insert.image";var h=l.InsertImageEvent=u;class g extends CustomEvent{constructor(e,t){super(g.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}g.TYPE="delete.sound";var b=l.DeleteSoundEvent=g;class m extends CustomEvent{constructor(e){super(m.TYPE,{bubbles:!0,detail:e}),this.handler=e}}m.TYPE="insert.sound";var _,E=l.InsertSoundEvent=m,f=e;_=f.createRoot,f.hydrateRoot;const C=t,I=n,{Typography:v}=i,{styled:S}=a,{FeedbackSelector:x}=s,{InputContainer:y}=s,{settings:k}=s,{layout:P}=s,w=o,{ALL_PLUGINS:M}=o;function T(e){let t,n=e[0],i=1;for(;i<e.length;){const a=e[i],s=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==n)return;"access"===a||"optionalAccess"===a?(t=n,n=s(n)):"call"!==a&&"optionalCall"!==a||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}const{Panel:A,toggle:D,numberFields:R,dropdown:q}=k,Y={type:"default",default:"Your answer has been submitted"},O=S(v)(({theme:e})=>({paddingBottom:e.spacing(1)})),j=S(y)(({theme:e})=>({paddingTop:e.spacing(1),marginTop:e.spacing(2),marginBottom:e.spacing(2),width:"100%"})),H=S("div")(({theme:e})=>({fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing(1)}));class F extends C.Component{static __initStatic(){this.propTypes={onModelChanged:I.func.isRequired,onConfigurationChanged:I.func,model:I.object.isRequired,configuration:I.object.isRequired,imageSupport:I.object.isRequired,uploadSoundSupport:I.object.isRequired}}constructor(e){super(e),F.prototype.__init.call(this),F.prototype.__init2.call(this),F.prototype.__init3.call(this),this.state={setDimensions:!0}}__init(){this.onPromptChange=e=>{const{onModelChanged:t,model:n}=this.props;t({...n,prompt:e})}}__init2(){this.changeFeedback=e=>{const{model:t,onModelChanged:n}=this.props;n({...t,feedback:e})}}__init3(){this.changeTeacherInstructions=e=>{const{model:t,onModelChanged:n}=this.props;n({...t,teacherInstructions:e})}}render(){const{model:e,configuration:t,imageSupport:n,onConfigurationChanged:i,onModelChanged:a,uploadSoundSupport:s}=this.props,{annotations:o={},contentDimensions:l={},dimensions:r={},equationEditor:d={},feedback:c={},playerSpellCheck:p={},prompt:u={},settingsPanelDisabled:h,spanishInput:g={},specialInput:b={},spellCheck:m={},studentInstructions:_={},teacherInstructions:E={},mathInput:f={},maxImageWidth:I={},maxImageHeight:v={},multiple:S={},withRubric:y={},mathMlOptions:k={},baseInputConfiguration:F={}}=t||{},{errors:G={},extraCSSRules:W,feedbackEnabled:L,promptEnabled:z,spellCheckEnabled:N,teacherInstructionsEnabled:B,toolbarEditorPosition:U}=e||{},{prompt:J,teacherInstructions:K}=G,Q=I&&I.prompt,V=v&&v.prompt,X={position:"top"===U?"top":"bottom"},Z={mathInput:f.settings&&D(f.label),equationEditor:d.enabled&&e.mathInput&&q(d.label,["non-negative-integers","integers","decimals","fractions","Grade 1 - 2","Grade 3 - 5","Grade 6 - 7","Grade 8 - HS","geometry","advanced-algebra","statistics","item-authoring"]),spanishInput:g.settings&&D(g.label),specialInput:b.settings&&D(b.label),dimensions:r.settings&&R(r.label,{width:{label:"Width (px)",suffix:"px",min:100,max:1200},height:{label:"Height (px)",suffix:"px",min:100,max:500}}),"multiple.enabled":S.settings&&D(S.label,!0),promptEnabled:u.settings&&D(u.label),feedbackEnabled:c.settings&&D(c.label),annotationsEnabled:o.settings&&D(o.label),spellCheckEnabled:m.settings&&D(m.label),playerSpellCheckDisabled:p.settings&&D(p.label)},$={teacherInstructionsEnabled:E.settings&&D(E.label),studentInstructionsEnabled:_.settings&&D(_.label),rubricEnabled:T([y,"optionalAccess",e=>e.settings])&&D(T([y,"optionalAccess",e=>e.label]))},ee=e=>Object.assign({...F},e||{});return C.createElement(P.ConfigLayout,{extraCSSRules:W,dimensions:l,hideSettings:h,settings:C.createElement(A,{model:e,configuration:t,onChangeModel:e=>a(e),onChangeConfiguration:e=>i(e),groups:{Settings:Z,Properties:$}})},B&&C.createElement(j,{label:E.label},C.createElement(w,{className:"prompt",markup:e.teacherInstructions||"",onChange:this.changeTeacherInstructions,imageSupport:n,nonEmpty:!1,error:K,toolbarOpts:X,spellCheck:N,maxImageWidth:I&&I.teacherInstructions||Q,maxImageHeight:v&&v.teacherInstructions||V,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:k,pluginProps:ee(T([E,"optionalAccess",e=>e.inputConfiguration]))}),K&&C.createElement(H,null,K)),z&&C.createElement(j,{label:u.label},C.createElement(w,{activePlugins:M,className:"prompt",markup:e.prompt||"",onChange:this.onPromptChange,imageSupport:n,nonEmpty:!1,error:J,toolbarOpts:X,spellCheck:N,maxImageWidth:Q,maxImageHeight:V,uploadSoundSupport:s,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:k,pluginProps:ee(T([u,"optionalAccess",e=>e.inputConfiguration]))}),J&&C.createElement(H,null,J)),L&&C.createElement(C.Fragment,null,C.createElement(O,{variant:"h6"},"Feedback"),C.createElement(x,{label:"When submitted, show",feedback:e.feedback||Y,onChange:this.changeFeedback,toolbarOpts:X})))}}F.__initStatic();var G={annotationsEnabled:!1,dimensions:{height:100,width:500},equationEditor:"Grade 8 - HS",feedbackEnabled:!1,mathInput:!1,playerSpellCheckDisabled:!0,predefinedAnnotations:[{label:"good",text:"good",type:"positive"},{label:"★",text:"★",type:"positive"},{label:":-)",text:":-)",type:"positive"},{label:"creative",text:"creative",type:"positive"},{label:"run-on",text:"run-on",type:"negative"},{label:"frag",text:"fragment",type:"negative"},{label:"tran",text:"transition",type:"negative"},{label:"supp",text:"support needed",type:"negative"},{label:"punc",text:"punctuation",type:"negative"},{label:"agr",text:"agreement wrong",type:"negative"},{label:"unclear",text:"unclear",type:"negative"},{label:"cut",text:"cut",type:"negative"},{label:"sp",text:"spelling",type:"negative"},{label:"cap",text:"capitalization",type:"negative"},{label:"inf",text:"informal",type:"negative"},{label:"awk",text:"awkward",type:"negative"}],prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,spanishInput:!1,specialInput:!1,spellCheckEnabled:!0,studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom"},W={annotations:{settings:!1,label:"Annotations"},baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},h3:{disabled:!0},blockquote:{disabled:!0},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},dimensions:{settings:!0,label:"Text-Entry Display Size"},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},playerSpellCheck:{label:"Disable Student Spellcheck",settings:!0,enabled:!0},equationEditor:{settings:!1,label:"Equation Editor",enabled:!0},feedback:{settings:!0,label:"Feedback"},mathInput:{settings:!0,label:"Student response can include math notation",enabled:!1},settingsPanelDisabled:!1,spanishInput:{settings:!0,label:"Students can insert Spanish",enabled:!1},specialInput:{settings:!0,label:"Students can insert Special Characters",enabled:!1},multiple:{settings:!1,label:"Multiple Parts",enabled:!1},studentInstructions:{settings:!1,label:"Student Instructions"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},maxImageWidth:{teacherInstructions:300,prompt:300},maxImageHeight:{teacherInstructions:300,prompt:300},withRubric:{settings:!1,label:"Add Rubric"},mathMlOptions:{mmlOutput:!1,mmlEditing:!1}};const L=t;function z(e){let t,n=e[0],i=1;for(;i<e.length;){const a=e[i],s=e[i+1];if(i+=2,("optionalAccess"===a||"optionalCall"===a)&&null==n)return;"access"===a||"optionalAccess"===a?(t=n,n=s(n)):"call"!==a&&"optionalCall"!==a||(n=s((...e)=>n.call(t,...e)),t=void 0)}return n}class N extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={},t)=>{const n={...G,...e};return z([t,"optionalAccess",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&!n.rubricEnabled&&(n.rubricEnabled=!0),n}}constructor(){super(),this._root=null,this._configuration=W,z([this,"access",e=>e._configuration,"access",e=>e.withRubric,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1),this._model=N.createDefaultModel({},this._configuration)}set model(e){this._model=N.createDefaultModel(e,this._configuration),this.render()}set configuration(e){this._configuration={...W,...e};const{withRubric:t={}}=e||{};z([t,"optionalAccess",e=>e.forceEnabled])&&(this._configuration.withRubric.settings=!1,this._model.rubricEnabled||(this._model.rubricEnabled=!0)),this.render()}onModelChanged(e){this._model=e,this.render(),this.dispatchEvent(new d(this._model,!1))}onConfigurationChanged(e){this._configuration={...W,...e},this._model&&this.onModelChanged(this._model),this.render()}insertImage(e){this.dispatchEvent(new h(e))}onDeleteImage(e,t){this.dispatchEvent(new p(e,t))}insertSound(e){this.dispatchEvent(new E(e))}onDeleteSound(e,t){this.dispatchEvent(new b(e,t))}render(){if(this._model){const e=L.createElement(F,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged.bind(this),onConfigurationChanged:this.onConfigurationChanged.bind(this),imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});this._root||(this._root=_(this)),this._root.render(e)}}disconnectedCallback(){this._root&&this._root.unmount()}}N.__initStatic();export{N as default};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the feedback from a {FeedbackConfig}
|
|
3
|
+
*
|
|
4
|
+
* @param {FeedbackConfig} feedback
|
|
5
|
+
* @param {string} fallback
|
|
6
|
+
*/
|
|
7
|
+
const getFeedback = (feedback, fallback) =>
|
|
8
|
+
new Promise((resolve) => {
|
|
9
|
+
if (!feedback || feedback.type === 'none') {
|
|
10
|
+
resolve(undefined);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
feedback = feedback || {};
|
|
14
|
+
const out = feedback[feedback.type] || fallback;
|
|
15
|
+
resolve(out);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
var defaults = {
|
|
19
|
+
annotationsEnabled: false,
|
|
20
|
+
dimensions: { height: 100, width: 500 },
|
|
21
|
+
equationEditor: 'Grade 8 - HS',
|
|
22
|
+
feedbackEnabled: false,
|
|
23
|
+
mathInput: false,
|
|
24
|
+
playerSpellCheckDisabled: true,
|
|
25
|
+
predefinedAnnotations: [
|
|
26
|
+
{ label: 'good', text: 'good', type: 'positive' },
|
|
27
|
+
{ label: '★', text: '★', type: 'positive' },
|
|
28
|
+
{ label: ':-)', text: ':-)', type: 'positive' },
|
|
29
|
+
{ label: 'creative', text: 'creative', type: 'positive' },
|
|
30
|
+
{ label: 'run-on', text: 'run-on', type: 'negative' },
|
|
31
|
+
{ label: 'frag', text: 'fragment', type: 'negative' },
|
|
32
|
+
{ label: 'tran', text: 'transition', type: 'negative' },
|
|
33
|
+
{ label: 'supp', text: 'support needed', type: 'negative' },
|
|
34
|
+
{ label: 'punc', text: 'punctuation', type: 'negative' },
|
|
35
|
+
{ label: 'agr', text: 'agreement wrong', type: 'negative' },
|
|
36
|
+
{ label: 'unclear', text: 'unclear', type: 'negative' },
|
|
37
|
+
{ label: 'cut', text: 'cut', type: 'negative' },
|
|
38
|
+
{ label: 'sp', text: 'spelling', type: 'negative' },
|
|
39
|
+
{ label: 'cap', text: 'capitalization', type: 'negative' },
|
|
40
|
+
{ label: 'inf', text: 'informal', type: 'negative' },
|
|
41
|
+
{ label: 'awk', text: 'awkward', type: 'negative' },
|
|
42
|
+
],
|
|
43
|
+
prompt: '',
|
|
44
|
+
promptEnabled: true,
|
|
45
|
+
rationale: '',
|
|
46
|
+
rationaleEnabled: true,
|
|
47
|
+
studentInstructionsEnabled: true,
|
|
48
|
+
teacherInstructions: '',
|
|
49
|
+
teacherInstructionsEnabled: true,
|
|
50
|
+
toolbarEditorPosition: 'bottom',
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
async function createDefaultModel(model = {}) {
|
|
54
|
+
|
|
55
|
+
return { ...defaults, ...model };
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const normalize = (question) => ({ ...defaults, ...question });
|
|
59
|
+
|
|
60
|
+
async function model(question, session, env) {
|
|
61
|
+
const normalizedQuestion = normalize(question);
|
|
62
|
+
|
|
63
|
+
const fb =
|
|
64
|
+
env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled
|
|
65
|
+
? getFeedback(normalizedQuestion.feedback, 'Your answer has been submitted')
|
|
66
|
+
: Promise.resolve(undefined);
|
|
67
|
+
|
|
68
|
+
let teacherInstructions = null;
|
|
69
|
+
if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
|
|
70
|
+
teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
|
|
71
|
+
} else {
|
|
72
|
+
teacherInstructions = null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let equationEditor = normalizedQuestion.equationEditor || 'miscellaneous';
|
|
76
|
+
|
|
77
|
+
switch (normalizedQuestion.equationEditor) {
|
|
78
|
+
case 'Grade 1 - 2':
|
|
79
|
+
equationEditor = 1;
|
|
80
|
+
break;
|
|
81
|
+
case 'Grade 3 - 5':
|
|
82
|
+
equationEditor = 3;
|
|
83
|
+
break;
|
|
84
|
+
case 'Grade 6 - 7':
|
|
85
|
+
equationEditor = 6;
|
|
86
|
+
break;
|
|
87
|
+
case 'Grade 8 - HS':
|
|
88
|
+
equationEditor = 8;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const annotatorMode = normalizedQuestion.annotationsEnabled && (env.role === 'instructor' || env.mode === 'evaluate');
|
|
93
|
+
|
|
94
|
+
return fb.then((feedback) => ({
|
|
95
|
+
prompt: normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null,
|
|
96
|
+
dimensions: normalizedQuestion.dimensions,
|
|
97
|
+
customKeys: normalizedQuestion.customKeys || [],
|
|
98
|
+
id: normalizedQuestion.id,
|
|
99
|
+
disabled: env.mode !== 'gather',
|
|
100
|
+
feedback,
|
|
101
|
+
teacherInstructions,
|
|
102
|
+
language: normalizedQuestion.language,
|
|
103
|
+
mathInput: normalizedQuestion.mathInput,
|
|
104
|
+
spanishInput: normalizedQuestion.spanishInput,
|
|
105
|
+
specialInput: normalizedQuestion.specialInput,
|
|
106
|
+
equationEditor,
|
|
107
|
+
spellCheckEnabled: !normalizedQuestion.playerSpellCheckDisabled,
|
|
108
|
+
playersToolbarPosition: normalizedQuestion.playersToolbarPosition || 'bottom',
|
|
109
|
+
annotatorMode,
|
|
110
|
+
disabledAnnotator: normalizedQuestion.annotationsEnabled ? env.role !== 'instructor' : true,
|
|
111
|
+
predefinedAnnotations: normalizedQuestion.annotationsEnabled ? normalizedQuestion.predefinedAnnotations : [],
|
|
112
|
+
extraCSSRules: normalizedQuestion.extraCSSRules,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async function outcome(/*question, session, env*/) {
|
|
117
|
+
return {
|
|
118
|
+
score: 0,
|
|
119
|
+
completed: 'n/a',
|
|
120
|
+
note: 'Requires manual scoring',
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// remove all html tags except img, iframe and source tag for audio
|
|
125
|
+
const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
|
|
126
|
+
|
|
127
|
+
const validate = (model = {}, config = {}) => {
|
|
128
|
+
const errors = {};
|
|
129
|
+
|
|
130
|
+
['teacherInstructions', 'prompt'].forEach((field) => {
|
|
131
|
+
if (config[field]?.required && !getContent(model[field])) {
|
|
132
|
+
errors[field] = 'This field is required.';
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
return errors;
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
export { createDefaultModel, model, normalize, outcome, validate };
|
package/module/demo.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import Configure from './configure.js';
|
|
2
|
+
import Element from './element.js';
|
|
3
|
+
import * as controller from './controller.js';
|
|
4
|
+
|
|
5
|
+
var generate = {};
|
|
6
|
+
|
|
7
|
+
generate.model = (id, element) => ({
|
|
8
|
+
id,
|
|
9
|
+
element,
|
|
10
|
+
customKeys: ['\\square'],
|
|
11
|
+
feedback: { type: 'default', default: 'this is default feedback' },
|
|
12
|
+
prompt: 'This is the question prompt',
|
|
13
|
+
promptEnabled: true,
|
|
14
|
+
mathInput: true,
|
|
15
|
+
playersToolbarPosition: 'bottom',
|
|
16
|
+
toolbarEditorPosition: 'bottom',
|
|
17
|
+
spellCheckEnabled: true,
|
|
18
|
+
rubricEnabled: false,
|
|
19
|
+
annotationsEnabled: false,
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
const { model } = generate;
|
|
23
|
+
var config = {
|
|
24
|
+
elements: {
|
|
25
|
+
'extended-text-entry': '../..',
|
|
26
|
+
},
|
|
27
|
+
models: [model('1', 'extended-text-entry')],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//Note: demo-el is a custom element loaded in the markup.
|
|
31
|
+
customElements.whenDefined("demo-el").then(() => {
|
|
32
|
+
config.models.forEach((m) => {
|
|
33
|
+
const de = document.createElement("demo-el");
|
|
34
|
+
document.body.appendChild(de);
|
|
35
|
+
de.def = { tagName: m.element, Element, Configure, controller };
|
|
36
|
+
de.model = m;
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{_dll_prop_types as e,_dll_mui__material as t,_dll_mui__material_styles as n,_dll_lodash as o,_dll_debug as r,_dll_pie_lib__render_ui as i,_dll_react_dom as s}from"../../../@pie-lib/shared-module@^3.0.5/module/index.js";import{_dll_pie_lib__math_rendering as a}from"../../../@pie-lib/math-rendering-module@^4.0.5/module/index.js";import{_dll_pie_lib__editable_html_tip_tap as l}from"../../../@pie-lib/editable-html-module@^6.0.5/module/index.js";import{_dll_pie_lib__config_ui as c}from"../../../@pie-lib/config-module@^3.0.0/module/index.js";var d={exports:{}},p={},u=Symbol.for("react.element"),h=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),m=Symbol.for("react.strict_mode"),g=Symbol.for("react.profiler"),y=Symbol.for("react.provider"),b=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),_=Symbol.for("react.memo"),x=Symbol.for("react.lazy"),E=Symbol.iterator;var S={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,k={};function R(e,t,n){this.props=e,this.context=t,this.refs=k,this.updater=n||S}function A(){}function T(e,t,n){this.props=e,this.context=t,this.refs=k,this.updater=n||S}R.prototype.isReactComponent={},R.prototype.setState=function(e,t){if("object"!=typeof e&&"function"!=typeof e&&null!=e)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")},R.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")},A.prototype=R.prototype;var P=T.prototype=new A;P.constructor=T,w(P,R.prototype),P.isPureReactComponent=!0;var L=Array.isArray,M=Object.prototype.hasOwnProperty,I={current:null},$={key:!0,ref:!0,__self:!0,__source:!0};function N(e,t,n){var o,r={},i=null,s=null;if(null!=t)for(o in void 0!==t.ref&&(s=t.ref),void 0!==t.key&&(i=""+t.key),t)M.call(t,o)&&!$.hasOwnProperty(o)&&(r[o]=t[o]);var a=arguments.length-2;if(1===a)r.children=n;else if(1<a){for(var l=Array(a),c=0;c<a;c++)l[c]=arguments[c+2];r.children=l}if(e&&e.defaultProps)for(o in a=e.defaultProps)void 0===r[o]&&(r[o]=a[o]);return{$$typeof:u,type:e,key:i,ref:s,props:r,_owner:I.current}}function D(e){return"object"==typeof e&&null!==e&&e.$$typeof===u}var O=/\/+/g;function j(e,t){return"object"==typeof e&&null!==e&&null!=e.key?function(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(e){return t[e]})}(""+e.key):t.toString(36)}function H(e,t,n,o,r){var i=typeof e;"undefined"!==i&&"boolean"!==i||(e=null);var s=!1;if(null===e)s=!0;else switch(i){case"string":case"number":s=!0;break;case"object":switch(e.$$typeof){case u:case h:s=!0}}if(s)return r=r(s=e),e=""===o?"."+j(s,0):o,L(r)?(n="",null!=e&&(n=e.replace(O,"$&/")+"/"),H(r,t,n,"",function(e){return e})):null!=r&&(D(r)&&(r=function(e,t){return{$$typeof:u,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}(r,n+(!r.key||s&&s.key===r.key?"":(""+r.key).replace(O,"$&/")+"/")+e)),t.push(r)),1;if(s=0,o=""===o?".":o+":",L(e))for(var a=0;a<e.length;a++){var l=o+j(i=e[a],a);s+=H(i,t,n,l,r)}else if(l=function(e){return null===e||"object"!=typeof e?null:"function"==typeof(e=E&&e[E]||e["@@iterator"])?e:null}(e),"function"==typeof l)for(e=l.call(e),a=0;!(i=e.next()).done;)s+=H(i=i.value,t,n,l=o+j(i,a++),r);else if("object"===i)throw t=String(e),Error("Objects are not valid as a React child (found: "+("[object Object]"===t?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return s}function W(e,t,n){if(null==e)return e;var o=[],r=0;return H(e,o,"","",function(e){return t.call(n,e,r++)}),o}function z(e){if(-1===e._status){var t=e._result;(t=t()).then(function(t){0!==e._status&&-1!==e._status||(e._status=1,e._result=t)},function(t){0!==e._status&&-1!==e._status||(e._status=2,e._result=t)}),-1===e._status&&(e._status=0,e._result=t)}if(1===e._status)return e._result.default;throw e._result}var q={current:null},V={transition:null},U={ReactCurrentDispatcher:q,ReactCurrentBatchConfig:V,ReactCurrentOwner:I};function F(){throw Error("act(...) is not supported in production builds of React.")}p.Children={map:W,forEach:function(e,t,n){W(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return W(e,function(){t++}),t},toArray:function(e){return W(e,function(e){return e})||[]},only:function(e){if(!D(e))throw Error("React.Children.only expected to receive a single React element child.");return e}},p.Component=R,p.Fragment=f,p.Profiler=g,p.PureComponent=T,p.StrictMode=m,p.Suspense=C,p.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=U,p.act=F,p.cloneElement=function(e,t,n){if(null==e)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var o=w({},e.props),r=e.key,i=e.ref,s=e._owner;if(null!=t){if(void 0!==t.ref&&(i=t.ref,s=I.current),void 0!==t.key&&(r=""+t.key),e.type&&e.type.defaultProps)var a=e.type.defaultProps;for(l in t)M.call(t,l)&&!$.hasOwnProperty(l)&&(o[l]=void 0===t[l]&&void 0!==a?a[l]:t[l])}var l=arguments.length-2;if(1===l)o.children=n;else if(1<l){a=Array(l);for(var c=0;c<l;c++)a[c]=arguments[c+2];o.children=a}return{$$typeof:u,type:e.type,key:r,ref:i,props:o,_owner:s}},p.createContext=function(e){return(e={$$typeof:b,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null}).Provider={$$typeof:y,_context:e},e.Consumer=e},p.createElement=N,p.createFactory=function(e){var t=N.bind(null,e);return t.type=e,t},p.createRef=function(){return{current:null}},p.forwardRef=function(e){return{$$typeof:v,render:e}},p.isValidElement=D,p.lazy=function(e){return{$$typeof:x,_payload:{_status:-1,_result:e},_init:z}},p.memo=function(e,t){return{$$typeof:_,type:e,compare:void 0===t?null:t}},p.startTransition=function(e){var t=V.transition;V.transition={};try{e()}finally{V.transition=t}},p.unstable_act=F,p.useCallback=function(e,t){return q.current.useCallback(e,t)},p.useContext=function(e){return q.current.useContext(e)},p.useDebugValue=function(){},p.useDeferredValue=function(e){return q.current.useDeferredValue(e)},p.useEffect=function(e,t){return q.current.useEffect(e,t)},p.useId=function(){return q.current.useId()},p.useImperativeHandle=function(e,t,n){return q.current.useImperativeHandle(e,t,n)},p.useInsertionEffect=function(e,t){return q.current.useInsertionEffect(e,t)},p.useLayoutEffect=function(e,t){return q.current.useLayoutEffect(e,t)},p.useMemo=function(e,t){return q.current.useMemo(e,t)},p.useReducer=function(e,t,n){return q.current.useReducer(e,t,n)},p.useRef=function(e){return q.current.useRef(e)},p.useState=function(e){return q.current.useState(e)},p.useSyncExternalStore=function(e,t,n){return q.current.useSyncExternalStore(e,t,n)},p.useTransition=function(){return q.current.useTransition()},p.version="18.3.1",d.exports=p;var B=d.exports;const K=(e,t,n)=>{const o=n||[],r=o.reduce((e,t)=>e+t.textContent.length,0);let i=!0;if(r>t)return!1;for(e&&(3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&o.push(e),e=e.firstChild);e&&i;)i=K(e,t,o),e=e.nextSibling;return o},Y=e=>{const{commonAncestorContainer:t,startContainer:n,endContainer:o,startOffset:r,endOffset:i}=e,s=[];let a=!1,l=!1,c="";const d=e=>{const{nodeValue:t,childNodes:p}=e;e===n&&e===o?(t&&(c+=t.substring(r,i)),a=l=!0):e===n?(t&&(c+=t.substring(r)),a=!0):e===o?(t&&(c+=t.substring(0,i)),l=!0):e&&3===e.nodeType&&e.parentNode&&!e.parentNode.hasAttribute("data-ann-id")&&t&&a&&!l&&(c+=t,s.push(e)),p.forEach(e=>{l||d(e)})};return d(t),[s,c]},G=e=>{const t=document.createElement("SPAN");return e.surroundContents(t),t},X=e=>{if(e.startContainer===e.endContainer)return[G(e)];const[t]=Y(e),n=document.createRange();n.selectNodeContents(e.startContainer),n.setStart(e.startContainer,e.startOffset);const o=G(n),r=document.createRange();r.selectNode(e.endContainer),r.setEnd(e.endContainer,e.endOffset);const i=G(r);return[o,...t.map(e=>{const t=document.createElement("SPAN");return e.parentNode.insertBefore(t,e),t.appendChild(e),t}),i]},Q=(e,t)=>{(e||[]).forEach(e=>{const t=e.parentNode,n=e.childNodes,o=n.length;if(o>0)for(let r=0;r<o;r++)t.insertBefore(n[0],e);else t.insertBefore(document.createTextNode(e.textContent),e);t.removeChild(e)}),t.normalize()},J=()=>{document.getSelection?(document.getSelection().removeAllRanges(),document.getSelection().addRange(document.createRange())):window.getSelection?window.getSelection().removeAllRanges?(window.getSelection().removeAllRanges(),window.getSelection().addRange(document.createRange())):window.getSelection().empty&&window.getSelection().empty():document.selection&&document.selection.empty()},Z=e=>e.length>=20||-1!==e.search(/\n|\r|\r\n/),ee=e=>Array.from(document.querySelectorAll(`[data-id='${e}']`)),te=e=>document.querySelector(`[data-ann-id='${e}']`),ne=e,{Popover:oe}=t,{TextField:re}=t,{styled:ie}=n,se=ie(oe)(({theme:e,annotationType:t})=>({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginLeft:"16px","&::before":{position:"absolute",right:"100%",top:"13px",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderRightColor:e.palette.grey[100]},..."negative"===t&&{"&::before":{borderRightColor:"rgb(255, 204, 238) !important"}},..."positive"===t&&{"&::before":{borderRightColor:"rgb(153, 255, 153) !important"}}}})),ae=ie("div")(({theme:e,annotationType:t})=>({width:"200px",overflow:"hidden",borderRadius:"4px",backgroundColor:"#ffffff",border:`4px solid ${e.palette.grey[100]}`,..."negative"===t&&{borderColor:"rgb(255, 204, 238) !important"},..."positive"===t&&{borderColor:"rgb(153, 255, 153) !important"}})),le=ie("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),ce=ie("div")(({theme:e,variant:t,annotationType:n})=>({flexGrow:1,width:"28%",textAlign:"center",padding:"4px",cursor:"pointer","&:not(:nth-child(3n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}},..."typeChange"===t&&"negative"===n&&{"&:hover":{backgroundColor:"rgb(153, 255, 153) !important"}},..."typeChange"===t&&"positive"===n&&{"&:hover":{backgroundColor:"rgb(255, 204, 238) !important"}}}));class de extends B.Component{static __initStatic(){this.propTypes={anchorEl:ne.object,open:ne.bool,offset:ne.number,value:ne.string,type:ne.string,onClose:ne.func,onDelete:ne.func,onSave:ne.func,onTypeChange:ne.func}}constructor(e){super(e),de.prototype.__init.call(this),de.prototype.__init2.call(this),de.prototype.__init3.call(this),this.state={value:e.value}}UNSAFE_componentWillReceiveProps(e){const{value:t}=e,{value:n}=this.props;t!==n&&this.setState({value:t})}__init(){this.onValueChange=e=>this.setState({value:e.target.value})}__init2(){this.handleSave=()=>{const{value:e,onSave:t,onClose:n,onDelete:o}=this.props,{value:r}=this.state;""===r&&o(),e!==r&&t(e,r),this.setState({value:""}),n()}}__init3(){this.handleTypeChange=()=>{const{onTypeChange:e,onDelete:t}=this.props,{value:n}=this.state;""===n?t():e(n),this.setState({value:""})}}render(){const{anchorEl:e,offset:t,onDelete:n,open:o,type:r}=this.props,{value:i}=this.state;return B.createElement(se,{anchorEl:e,elevation:2,open:o,onClose:this.handleSave,annotationType:r,style:{marginTop:`${t}px`,transition:"margin-top 2s ease-out"},transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"}},B.createElement(ae,{annotationType:r},B.createElement(re,{id:"annotation-editor",style:{padding:"2px 5px",width:"95%"},autoFocus:!0,multiline:!0,rows:1,maxRows:4,value:i,onChange:this.onValueChange,InputProps:{disableUnderline:!0}}),B.createElement(le,null,B.createElement(ce,{onClick:n},"Delete"),B.createElement(ce,{variant:"typeChange",annotationType:r,onClick:this.handleTypeChange},"negative"===r?"Green":"Pink"),B.createElement(ce,{onClick:this.handleSave},"Save"))))}}de.__initStatic();const pe=e,{styled:ue}=n,{Popover:he}=t,fe=ue(he)({"& .MuiPaper-root":{overflowX:"unset",overflowY:"unset",marginTop:"-16px","&::after":{position:"absolute",left:"calc(50% - 7px)",border:"solid transparent",content:'""',height:0,width:0,pointerEvents:"none",borderWidth:"7px",borderTopColor:"black"}}}),me=ue("div")(({theme:e})=>({width:"300px",overflow:"hidden",borderRadius:"4px",backgroundColor:e.palette.common.white,border:`2px solid ${e.palette.grey[100]}`})),ge=ue("div")({display:"flex",flexWrap:"wrap"}),ye=ue("div")(({theme:e})=>({display:"flex",flexWrap:"wrap",borderTop:`2px solid ${e.palette.grey[100]}`})),be=ue("div")(({theme:e,variant:t})=>({width:"22%",textAlign:"center",padding:"4px",cursor:"pointer",borderBottom:`1px solid ${e.palette.grey[100]}`,"&:not(:nth-child(4n))":{borderRight:`1px solid ${e.palette.grey[100]}`},"&:nth-child(4n)":{flexGrow:1},"&:hover":{backgroundColor:e.palette.grey[100]},..."positive"===t&&{backgroundColor:"rgb(153, 255, 153) !important","&:hover":{filter:"brightness(85%)"}},..."negative"===t&&{backgroundColor:"rgb(255, 204, 238) !important","&:hover":{filter:"brightness(85%)"}}}));class ve extends B.Component{static __initStatic(){this.propTypes={anchorEl:pe.object,open:pe.bool,annotations:pe.array,isNewAnnotation:pe.bool,onClose:pe.func,onDelete:pe.func,onEdit:pe.func,onWrite:pe.func,onAnnotate:pe.func}}render(){const{anchorEl:e,annotations:t,isNewAnnotation:n,onAnnotate:o,onClose:r,onEdit:i,onDelete:s,onWrite:a,open:l}=this.props;return B.createElement(fe,{anchorEl:e,open:l,onClose:r,elevation:5,transitionDuration:{enter:225,exit:195},anchorOrigin:{vertical:"top",horizontal:"center"},transformOrigin:{vertical:"bottom",horizontal:"center"}},B.createElement(me,null,B.createElement(ge,null,t.map((e,t)=>B.createElement(be,{key:`annotation-${t}`,variant:e.type,onClick:()=>o(e)},e.label))),B.createElement(ye,null,B.createElement(be,{onClick:r},"Cancel"),B.createElement(be,{style:{pointerEvents:"none"}}),n?B.createElement(B.Fragment,null,B.createElement(be,{variant:"positive",onClick:()=>a("positive")},"Write"),B.createElement(be,{variant:"negative",onClick:()=>a("negative")},"Write")):B.createElement(B.Fragment,null,B.createElement(be,{onClick:s},"Delete"),B.createElement(be,{onClick:i},"Edit")))))}}ve.__initStatic();const{styled:Ce}=n,_e=e,xe=l,{InputContainer:Ee}=c,Se=Ce("div")({padding:"10px 120px 10px 16px",backgroundColor:"rgba(0, 0, 0, 0.06)",border:"1px solid #ccc",borderRadius:"4px",overflowY:"scroll",lineHeight:"36px",whiteSpace:"pre-wrap",overflowWrap:"break-word","& p":{margin:0},"& span[data-latex]":{userSelect:"none","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none"}}),we=Ce("div")({width:"230px"}),ke=Ce("div")({position:"relative",overflowX:"hidden",display:"flex"}),Re=Ce(Ee)(({theme:e})=>({paddingTop:e.spacing(2),marginBottom:e.spacing(2),marginTop:e.spacing(2),width:"100%"}));if(!document.getElementById("annotation-editor-styles")){const e=document.createElement("style");e.id="annotation-editor-styles",e.textContent='\n .sideAnnotation:before {\n position: absolute;\n right: var(--before-right, 100%);\n top: var(--before-top, 5px);\n border: solid transparent;\n content: "";\n height: 0;\n width: 0;\n pointer-events: none;\n border-width: var(--before-border-width, 7px);\n border-right-color: var(--before-border-color, rgb(153, 255, 153));\n }\n',document.head.appendChild(e)}class Ae extends B.Component{static __initStatic(){this.propTypes={text:_e.string,comment:_e.string,annotations:_e.array,predefinedAnnotations:_e.array,onChange:_e.func.isRequired,onCommentChange:_e.func.isRequired,width:_e.number,height:_e.number,maxHeight:_e.string,disabled:_e.bool,disabledMath:_e.bool,customKeys:_e.array,keypadMode:_e.string}}constructor(e){super(e),Ae.prototype.__init.call(this),Ae.prototype.__init2.call(this),Ae.prototype.__init3.call(this),Ae.prototype.__init4.call(this),Ae.prototype.__init5.call(this),Ae.prototype.__init6.call(this),Ae.prototype.__init7.call(this),Ae.prototype.__init8.call(this),Ae.prototype.__init9.call(this),Ae.prototype.__init10.call(this),Ae.prototype.__init11.call(this),Ae.prototype.__init12.call(this),Ae.prototype.__init13.call(this),Ae.prototype.__init14.call(this),Ae.prototype.__init15.call(this),this.state={anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotation:null,annotationIndex:null}}componentDidMount(){const{annotations:e,text:t}=this.props;t&&e.forEach(e=>{const[t,n]=((e,t,n)=>{const o=K(n,t),r=[];let i=0;return o.forEach(n=>{const o=i+n.textContent.length;[e,t].forEach(e=>{i<=e&&e<o&&r.push({node:n,offset:e-i})}),i=o}),r})(e.start,e.end,this.textRef);if(t&&n){const o=document.createRange();o.setStart(t.node,t.offset),o.setEnd(n.node,n.offset);const r=X(o);this.createDOMAnnotation(r,e)}}),this.textRef&&(this.adjustAnnotationsPosition(),this.textRef.addEventListener("scroll",this.adjustAnnotationsPosition))}__init(){this.adjustAnnotationsPosition=()=>{if(this.textRef&&this.labelsRef){const e=this.textRef.offsetLeft+this.textRef.offsetWidth+8;Array.from(this.labelsRef.children).forEach(t=>{const n=ee(t.dataset.annId),o=(n[0].offsetTop?n[0].offsetTop:n[0].offsetParent.offsetTop)-this.textRef.scrollTop-6;t.style.top=`${o}px`,t.style.left=`${e}px`})}}}__init2(){this.handleClick=e=>{const{annotations:t}=this.props,{selectionDetails:n}=this.state;if(n)return;const{id:o,annId:r}=e.target.dataset,i=o||r,s=ee(i),a=te(i),l=t.findIndex(e=>e.id===i),c=a.hasAttribute("data-freeform");c&&(a.style.zIndex="10"),this.setState({anchorEl:s[0],openedMenu:!!o||!!r&&!c,openedEditor:!!r&&c,selectedElems:s,labelElem:a,annotationIndex:l,annotation:t[l],selectionDetails:null})}}__init3(){this.handleHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,r=ee(o),i=te(o),s=i.hasAttribute("data-freeform");r.forEach(e=>{e.style.zIndex="20",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.7)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.55)")}),s?(i.style.zIndex="20",i.classList.contains("positive")?(i.style.backgroundColor="rgb(128, 255, 128)",i.style.setProperty("--before-border-color","rgb(153, 255, 153)")):i.classList.contains("negative")&&(i.style.backgroundColor="rgb(255, 179, 230)",i.style.setProperty("--before-border-color","rgb(255, 179, 230)"))):(i.style.zIndex="20",i.classList.contains("positive")?i.style.color="rgb(0, 77, 0)":i.classList.contains("negative")&&(i.style.color="rgb(153, 0, 102)"))}}__init4(){this.handleCancelHover=e=>{const{id:t,annId:n}=e.target.dataset,o=t||n,r=ee(o),i=te(o),s=i.hasAttribute("data-freeform");r.forEach(e=>{e.style.zIndex="",e.classList.contains("positive")?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":e.classList.contains("negative")&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)")}),s?(i.style.zIndex="",i.classList.contains("positive")?(i.style.backgroundColor="rgb(153, 255, 153)",i.style.removeProperty("--before-border-color")):i.classList.contains("negative")&&(i.style.backgroundColor="rgb(255, 204, 238)",i.style.removeProperty("--before-border-color"))):(i.style.zIndex="",i.classList.contains("positive")?i.style.color="rgb(0, 128, 0)":i.classList.contains("negative")&&(i.style.color="rgb(204, 0, 136)"))}}__init5(){this.handleClose=e=>{const{selectedElems:t,labelElem:n}=this.state;t.length&&!t[0].hasAttribute("data-id")&&Q(t,this.textRef),n&&(n.style.zIndex=""),this.setState({anchorEl:null,openedMenu:!1,openedEditor:!1,selectedElems:[],labelElem:null,selectionDetails:null,annotationIndex:null,annotation:null}),J()}}__init6(){this.handleSelection=e=>{const t=window.getSelection();if(e.detail>2)J();else if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=e.toString(),o=this.textRef.contains(e.commonAncestorContainer);if(!t.isCollapsed&&""!==n&&o){const t=((e,t)=>{const n=document.createRange();n.setStart(t,0),n.setEnd(e.startContainer,e.startOffset);const[,o]=Y(n),[,r]=Y(e),i=o.length;return{quote:r,start:i,end:i+r.length}})(e,this.textRef),n=X(e);this.setState({anchorEl:n[0],openedMenu:!0,selectedElems:n,selectionDetails:t})}}}}__init7(){this.deleteAnnotation=()=>{const{annotations:e,onChange:t}=this.props,{selectedElems:n,labelElem:o,annotationIndex:r,annotation:i}=this.state;(Z(i.label)?this.labelsRef:n[0]).removeChild(o),Q(n,this.textRef),e.splice(r,1),t(e),this.handleClose()}}__init8(){this.createDOMAnnotation=(e,t)=>{const{disabled:n}=this.props,{id:o,label:r,type:i}=t;(e||[]).forEach(e=>{e.dataset.id=o,e.className=`annotation ${i}`,e.style.position="relative",e.style.cursor="pointer","positive"===i?e.style.backgroundColor="rgb(51, 255, 51, 0.5)":"negative"===i&&(e.style.backgroundColor="rgba(255, 102, 204, 0.4)"),e.onclick=!n&&this.handleClick,e.onmouseover=this.handleHover,e.onmouseout=this.handleCancelHover});const s=e&&e[0]||{},a=document.createElement("SPAN");if(a.dataset.annId=o,a.innerHTML=r,a.onclick=!n&&this.handleClick,a.onmouseover=this.handleHover,a.onmouseout=this.handleCancelHover,Z(r)){const e=(s.offsetTop?s.offsetTop:s.offsetParent.offsetTop)-this.textRef.scrollTop,t=this.textRef.offsetLeft+this.textRef.offsetWidth+8;a.dataset.freeform=!0,a.className=`sideAnnotation ${i}`,a.style.position="absolute",a.style.padding="4px",a.style.borderRadius="4px",a.style.marginLeft="8px",a.style.width="180px",a.style.whiteSpace="pre-wrap",a.style.wordBreak="break-word",a.style.border="2px solid #ffffff",a.style.fontSize="14px",a.style.fontStyle="normal",a.style.fontWeight="normal",a.style.top=`${e}px`,a.style.left=`${t}px`,"negative"===i?a.style.backgroundColor="rgb(255, 204, 238)":"positive"===i&&(a.style.backgroundColor="rgb(153, 255, 153)"),a.style.setProperty("--before-border-width","7px"),a.style.setProperty("--before-top","5px"),a.style.setProperty("--before-right","100%"),"negative"===i?a.style.setProperty("--before-border-color","rgb(255, 204, 238)"):"positive"===i&&a.style.setProperty("--before-border-color","rgb(153, 255, 153)"),this.labelsRef.appendChild(a)}else a.className=`annotationLabel ${i}`,a.style.backgroundColor="rgb(242, 242, 242)",a.style.padding="2px",a.style.position="absolute",a.style.userSelect="none",a.style.whiteSpace="nowrap",a.style.top="-10px",a.style.left="-2px",a.style.fontSize="12px",a.style.fontStyle="normal",a.style.fontWeight="normal",a.style.lineHeight="6px",a.style.webkitUserSelect="none",a.style.mozUserSelect="none",a.style.msUserSelect="none","positive"===i?a.style.color="rgb(0, 128, 0)":"negative"===i&&(a.style.color="rgb(204, 0, 136)"),s.appendChild(a)}}__init9(){this.createNewAnnotation=(e,t)=>{const{selectedElems:n,selectionDetails:o}=this.state,r={id:[o.start,o.end,(new Date).getTime()].join("-"),label:e,type:t,...o};return this.createDOMAnnotation(n,r),r}}__init10(){this.handleMenuClick=e=>{const{annotations:t,onChange:n}=this.props,{annotation:o,annotationIndex:r}=this.state,{type:i,text:s}=e;if(o){const e={...o,label:s,type:i},{type:n,label:a}=o;this.updateLabel(a,e,i!==n&&n),t.splice(r,1,e)}else{const e=this.createNewAnnotation(s,i);t.push(e)}n(t),this.handleClose()}}__init11(){this.editAnnotation=()=>{this.setState({openedMenu:!1,openedEditor:!0})}}__init12(){this.addAnnotation=e=>{const{annotations:t,onChange:n}=this.props,o=this.createNewAnnotation("",e),r=te(o.id);t.push(o),this.setState({openedMenu:!1,openedEditor:!0,annotationIndex:t.length-1,annotation:o,labelElem:r}),n(t)}}__init13(){this.updateLabel=(e,t,n)=>{const{selectedElems:o,labelElem:r}=this.state,{label:i,type:s}=t;Z(i)&&Z(e)||!Z(i)&&!Z(e)?(r.innerHTML=i,n&&(r.classList.remove(n),r.classList.add(s),o.forEach(e=>{e.classList.remove(n),e.classList.add(s)}))):Z(i)&&!Z(e)?(o[0].removeChild(r),this.createDOMAnnotation(o,t)):!Z(i)&&Z(e)&&(this.labelsRef.removeChild(r),this.createDOMAnnotation(o,t))}}__init14(){this.changeAnnotationType=e=>{const{annotations:t,onChange:n}=this.props,{annotationIndex:o,selectedElems:r}=this.state,{type:i,label:s}=t[o],a="positive"===i?"negative":"positive",l={...t[o],type:a,label:e};r.forEach(e=>{e.classList.remove(i),e.classList.add(a)}),this.updateLabel(s,l,i),t.splice(o,1,l),n(t),this.handleClose()}}__init15(){this.updateAnnotation=(e,t)=>{const{annotations:n,onChange:o}=this.props,{annotationIndex:r}=this.state,i={...n[r],label:t};this.updateLabel(e,i),n.splice(r,1,i),o(n)}}componentWillUnmount(){this.textRef.removeEventListener("scroll",this.adjustAnnotationsPosition)}render(){const{comment:e,customKeys:t,disabled:n,disabledMath:o,keypadMode:r,height:i,width:s,maxHeight:a,onCommentChange:l,predefinedAnnotations:c,text:d}=this.props,{anchorEl:p,annotation:u,openedMenu:h,openedEditor:f,selectionDetails:m}=this.state,g=p&&(p.offsetTop?p.offsetTop:p.offsetParent.offsetTop),y=this.textRef&&g?g-this.textRef.scrollTop-8:0;return B.createElement("div",null,B.createElement(ke,null,B.createElement(Se,{style:{width:s-34,minHeight:i,maxHeight:a},ref:e=>this.textRef=e,onMouseDown:n?()=>{}:J,onMouseUp:n?()=>{}:this.handleSelection,dangerouslySetInnerHTML:{__html:d}}),B.createElement(we,{ref:e=>this.labelsRef=e})),B.createElement(Re,{label:"Comment"},B.createElement(xe,{className:"prompt",markup:e||"",onChange:l,width:s&&(s+104).toString(),disabled:n,pluginProps:{math:{disabled:o,customKeys:t,keypadMode:r,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},textAlign:{disabled:!0}}})),B.createElement(ve,{anchorEl:p,open:h&&!n,annotations:c,isNewAnnotation:!!m,onClose:this.handleClose,onDelete:this.deleteAnnotation,onEdit:this.editAnnotation,onWrite:this.addAnnotation,onAnnotate:this.handleMenuClick}),B.createElement(de,{anchorEl:this.textRef,open:f&&!n,offset:y,value:u&&u.label||"",type:u&&u.type,onClose:this.handleClose,onDelete:this.deleteAnnotation,onSave:this.updateAnnotation,onTypeChange:this.changeAnnotationType}))}}Ae.__initStatic();const Te=e,{debounce:Pe}=o,Le=r,{Typography:Me}=t,{styled:Ie}=n,{color:$e}=i,{Feedback:Ne}=i,{Collapsible:De}=i,{PreviewPrompt:Oe}=i,{UiLayout:je}=i,He=l,We=Le("@pie-ui:extended-text-entry"),ze=Ie(je)({backgroundColor:$e.background(),color:$e.text()}),qe=Ie(Me)(({theme:e})=>({width:"100%",color:$e.text(),marginBottom:e.spacing(2),fontSize:"inherit"})),Ve=Ie("div")(({theme:e})=>({marginBottom:e.spacing(2)})),Ue=Ie(He)(({theme:e})=>({marginBottom:e.spacing(2),borderRadius:"4px"})),Fe=Ie("h2")({position:"absolute",left:"-10000px",top:"auto",width:"1px",height:"1px",overflow:"hidden"});class Be extends B.Component{constructor(...e){super(...e),Be.prototype.__init.call(this),Be.prototype.__init2.call(this)}static __initStatic(){this.propTypes={onValueChange:Te.func.isRequired,onAnnotationsChange:Te.func.isRequired,onCommentChange:Te.func.isRequired,model:Te.object,session:Te.shape({value:Te.string,annotations:Te.array,comment:Te.string}).isRequired}}__init(){this.changeSessionValue=Pe(this.props.onValueChange,1500)}__init2(){this.changeSessionComment=Pe(this.props.onCommentChange,1500)}render(){const{model:e,session:t,onAnnotationsChange:n}=this.props,{animationsDisabled:o,annotatorMode:r,customKeys:i,dimensions:s,disabled:a,disabledAnnotator:l,equationEditor:c,extraCSSRules:d,feedback:p,mathInput:u,playersToolbarPosition:h,predefinedAnnotations:f,prompt:m,spanishInput:g,specialInput:y,spellCheckEnabled:b,teacherInstructions:v}=e,{annotations:C,comment:_,value:x}=t,{width:E,height:S}=s||{},w="40vh",k={position:"top"===h?"top":"bottom"};We("[render] disabled? ",a);const R=B.createElement(Oe,{defaultClassName:"teacher-instructions",prompt:v}),A=[];return g&&A.push({language:"spanish"}),y&&A.push({language:"special"}),B.createElement(ze,{extraCSSRules:d,ref:e=>{this.containerRef=e}},B.createElement(Fe,null,"Constructed Response Question"),v&&B.createElement(Ve,null,o?R:B.createElement(De,{labels:{hidden:"Show Teacher Instructions",visible:"Hide Teacher Instructions"}},R)),m&&B.createElement(qe,{component:"span"},B.createElement(Oe,{defaultClassName:"prompt",prompt:e.prompt})),r?B.createElement(Ae,{text:x||"",annotations:C||[],comment:_||"",predefinedAnnotations:f||[],onChange:n,onCommentChange:this.changeSessionComment,width:E,height:S,maxHeight:w,disabled:l,disabledMath:!u,customKeys:i,keypadMode:c}):B.createElement(Ue,{className:"response-area-editor",onChange:this.changeSessionValue,markup:x||"",maxWidth:E&&E.toString(),minWidth:"100px",minHeight:S&&S.toString(),maxHeight:w,disabled:a,highlightShape:!0,toolbarOpts:k,spellCheck:b,charactersLimit:5e4,autoWidthToolbar:!0,pluginProps:{math:{disabled:!u,customKeys:this.props.model.customKeys,keypadMode:this.props.model.equationEditor,controlledKeypadMode:!1},video:{disabled:!0},audio:{disabled:!0},table:{disabled:!0},textAlign:{disabled:!0},separateParagraphs:{disabled:!1},ul_list:{disabled:!0},ol_list:{disabled:!0}},languageCharactersProps:A}),p&&B.createElement(Ne,{correctness:"correct",feedback:p}))}}Be.__initStatic();var Ke,Ye=s;Ke=Ye.createRoot,Ye.hydrateRoot;var Ge={};Object.defineProperty(Ge,"__esModule",{value:!0});class Xe extends CustomEvent{constructor(e,t,n){super(Xe.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e,hasModel:n}}),this.component=e,this.complete=t}}Xe.TYPE="model-set";var Qe=Ge.ModelSetEvent=Xe;class Je extends CustomEvent{constructor(e,t){super(Je.TYPE,{bubbles:!0,composed:!0,detail:{complete:t,component:e}}),this.component=e,this.complete=t}}Je.TYPE="session-changed";var Ze=Ge.SessionChangedEvent=Je;const et=r,{renderMath:tt}=a,nt=et("@pie-elements:extended-text-entry"),ot=void 0!==typeof window?new DOMParser:{parseFromString:e=>e};function rt(e){if("string"==typeof e)try{const t=ot.parseFromString(e,"text/html");return t.body.textContent}catch(t){return nt("tried to parse as dom and failed",e),e}}function it(e){const t=rt(e);return void 0!==t&&t.length>0}class st extends HTMLElement{constructor(){super(),this._model=null,this._session=null,this._root=null}setLangAttribute(){const e=this._model&&(this._model.language,1)?this._model.language:"",t=e?e.slice(0,2):"en";this.setAttribute("lang",t)}set model(e){this._model=e,this.dispatchEvent(new Qe(this.tagName.toLowerCase(),!1,!!this._model)),this.render()}set session(e){this._session=e,this.render()}get session(){return this._session}valueChange(e){this._session.value=e,this.dispatchEvent(new Ze(this.tagName.toLowerCase(),it(e))),this.render()}annotationsChange(e){this._session.annotations=e,this.dispatchEvent(new Ze(this.tagName.toLowerCase(),!0)),this.render()}commentChange(e){this._session.comment=e,this.dispatchEvent(new Ze(this.tagName.toLowerCase(),it(e))),this.render()}connectedCallback(){this.setAttribute("aria-label","Written Response Question"),this.setAttribute("role","region"),this.render()}render(){if(this._model&&this._session){let e=B.createElement(Be,{model:this._model,session:this._session,onValueChange:this.valueChange.bind(this),onAnnotationsChange:this.annotationsChange.bind(this),onCommentChange:this.commentChange.bind(this)});this.setLangAttribute(),this._root||(this._root=Ke(this)),this._root.render(e),queueMicrotask(()=>{tt(this)})}}disconnectedCallback(){this._root&&this._root.unmount()}}export{st as default,it as isComplete,rt as textContent};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>@pie-element/extended-text-entry@14.0.0-beta.1</title>
|
|
6
|
+
<script
|
|
7
|
+
type="module"
|
|
8
|
+
src="https://cdn.jsdelivr.net/npm/@pslb/demo-el@^1.0.0/dist/demo-el/demo-el.esm.js"></script>
|
|
9
|
+
|
|
10
|
+
<link
|
|
11
|
+
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
12
|
+
rel="stylesheet"
|
|
13
|
+
/>
|
|
14
|
+
<style>
|
|
15
|
+
html, body {
|
|
16
|
+
font-family: 'Roboto', sans-serif;
|
|
17
|
+
}
|
|
18
|
+
</style>
|
|
19
|
+
<script type="module" src="./demo.js"></script>
|
|
20
|
+
</head>
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pie-element/extended-text-entry",
|
|
3
|
+
"version": "14.0.0-beta.1",
|
|
4
|
+
"modules": [
|
|
5
|
+
{
|
|
6
|
+
"name": "@pie-lib/shared-module",
|
|
7
|
+
"version": "^3.0.5"
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"name": "@pie-lib/math-rendering-module",
|
|
11
|
+
"version": "^4.0.5"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "@pie-lib/editable-html-module",
|
|
15
|
+
"version": "^6.0.5"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "@pie-lib/config-module",
|
|
19
|
+
"version": "^3.0.0"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import PrintElement from './print.js';
|
|
2
|
+
|
|
3
|
+
var generate = {};
|
|
4
|
+
|
|
5
|
+
generate.model = (id, element) => ({
|
|
6
|
+
id,
|
|
7
|
+
element,
|
|
8
|
+
customKeys: ['\\square'],
|
|
9
|
+
feedback: { type: 'default', default: 'this is default feedback' },
|
|
10
|
+
prompt: 'This is the question prompt',
|
|
11
|
+
promptEnabled: true,
|
|
12
|
+
mathInput: true,
|
|
13
|
+
playersToolbarPosition: 'bottom',
|
|
14
|
+
toolbarEditorPosition: 'bottom',
|
|
15
|
+
spellCheckEnabled: true,
|
|
16
|
+
rubricEnabled: false,
|
|
17
|
+
annotationsEnabled: false,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const { model } = generate;
|
|
21
|
+
var config = {
|
|
22
|
+
elements: {
|
|
23
|
+
'extended-text-entry': '../..',
|
|
24
|
+
},
|
|
25
|
+
models: [model('1', 'extended-text-entry')],
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// new init - just shows off print!
|
|
29
|
+
|
|
30
|
+
const init = async () => {
|
|
31
|
+
console.log('define the element...');
|
|
32
|
+
await Promise.all(
|
|
33
|
+
config.models.map(async (m) => {
|
|
34
|
+
try {
|
|
35
|
+
const printTag = `${m.element}-print`;
|
|
36
|
+
if (customElements.get(printTag)) {
|
|
37
|
+
return true;
|
|
38
|
+
} else {
|
|
39
|
+
customElements.define(printTag, PrintElement);
|
|
40
|
+
await customElements.whenDefined(printTag);
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
} catch (e) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
console.log('now apply the model...');
|
|
50
|
+
config.models.forEach((m) => {
|
|
51
|
+
const printTag = `${m.element}-print`;
|
|
52
|
+
const h3s = document.createElement('h3');
|
|
53
|
+
h3s.textContent = 'student mode';
|
|
54
|
+
document.body.appendChild(h3s);
|
|
55
|
+
const de = document.createElement(printTag);
|
|
56
|
+
document.body.appendChild(de);
|
|
57
|
+
de.options = {};
|
|
58
|
+
de.model = m;
|
|
59
|
+
|
|
60
|
+
const h3 = document.createElement('h3');
|
|
61
|
+
h3.textContent = 'instructor mode';
|
|
62
|
+
document.body.appendChild(h3);
|
|
63
|
+
const instr = document.createElement(printTag);
|
|
64
|
+
document.body.appendChild(instr);
|
|
65
|
+
instr.options = { mode: 'instructor' };
|
|
66
|
+
instr.model = JSON.parse(JSON.stringify(m));
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
init()
|
|
71
|
+
.then(() => {
|
|
72
|
+
console.log('ready');
|
|
73
|
+
})
|
|
74
|
+
.catch((e) => {
|
|
75
|
+
console.error(e);
|
|
76
|
+
});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
|
|
2
|
+
<!doctype html>
|
|
3
|
+
<html>
|
|
4
|
+
<head>
|
|
5
|
+
<title>@pie-element/extended-text-entry@14.0.0-beta.1</title>
|
|
6
|
+
<link
|
|
7
|
+
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
|
|
8
|
+
rel="stylesheet"
|
|
9
|
+
/>
|
|
10
|
+
<style>
|
|
11
|
+
html, body {
|
|
12
|
+
font-family: 'Roboto', sans-serif;
|
|
13
|
+
}
|
|
14
|
+
</style>
|
|
15
|
+
<script type="module" src="./print-demo.js"></script>
|
|
16
|
+
</head>
|
|
17
|
+
<body></body>
|
|
18
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/extended-text-entry",
|
|
3
|
-
"version": "14.0.0-
|
|
3
|
+
"version": "14.0.0-next.42+bb1f3eb4e",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"@mui/icons-material": "^7.3.4",
|
|
15
15
|
"@mui/material": "^7.3.4",
|
|
16
16
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
17
|
-
"@pie-lib/config-ui": "12.1.
|
|
18
|
-
"@pie-lib/editable-html-tip-tap": "1.1.
|
|
19
|
-
"@pie-lib/math-rendering": "4.1.
|
|
20
|
-
"@pie-lib/render-ui": "5.1.
|
|
17
|
+
"@pie-lib/config-ui": "12.1.1-next.0",
|
|
18
|
+
"@pie-lib/editable-html-tip-tap": "1.1.1-next.0",
|
|
19
|
+
"@pie-lib/math-rendering": "4.1.1-next.0",
|
|
20
|
+
"@pie-lib/render-ui": "5.1.1-next.0",
|
|
21
21
|
"classnames": "^2.2.5",
|
|
22
22
|
"debug": "^4.1.1",
|
|
23
23
|
"lodash.throttle": "^4.1.1",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react": "18.2.0",
|
|
26
26
|
"react-dom": "18.2.0"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "bb1f3eb4e3b5b1cb15024d459ffd6e94bf419712",
|
|
29
29
|
"scripts": {
|
|
30
30
|
"postpublish": "../../scripts/postpublish"
|
|
31
31
|
},
|