@pie-element/drawing-response 6.5.3-next.0 → 6.5.3-next.29
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 +33 -0
- package/configure/lib/index.js.map +1 -1
- package/configure/package.json +2 -2
- package/configure/src/index.js +26 -0
- package/package.json +3 -3
package/configure/lib/index.js
CHANGED
|
@@ -97,6 +97,8 @@ var DrawableResponseConfigure = /*#__PURE__*/function (_HTMLElement) {
|
|
|
97
97
|
}, {
|
|
98
98
|
key: "configuration",
|
|
99
99
|
set: function set(c) {
|
|
100
|
+
var _this2 = this;
|
|
101
|
+
|
|
100
102
|
this._configuration = c;
|
|
101
103
|
|
|
102
104
|
var _ref = c || {},
|
|
@@ -112,6 +114,37 @@ var DrawableResponseConfigure = /*#__PURE__*/function (_HTMLElement) {
|
|
|
112
114
|
if (!this._model.rubricEnabled) {
|
|
113
115
|
this._model.rubricEnabled = true;
|
|
114
116
|
}
|
|
117
|
+
} // if language:enabled is true, then the corresponding default item model should include a language value;
|
|
118
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
119
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
120
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
if (c.language.enabled) {
|
|
124
|
+
var _c$languageChoices, _c$languageChoices$op;
|
|
125
|
+
|
|
126
|
+
if ((_c$languageChoices = c.languageChoices) !== null && _c$languageChoices !== void 0 && (_c$languageChoices$op = _c$languageChoices.options) !== null && _c$languageChoices$op !== void 0 && _c$languageChoices$op.length) {
|
|
127
|
+
this._model.language = c.languageChoices.options[0].value;
|
|
128
|
+
}
|
|
129
|
+
} else if (c.language.settings && this._model.language) {
|
|
130
|
+
this._configuration.language.enabled = true;
|
|
131
|
+
|
|
132
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
133
|
+
this._configuration.languageChoices.options = [];
|
|
134
|
+
} // check if the language is already included in the languageChoices.options array
|
|
135
|
+
// and if not, then add it.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
if (!this._configuration.languageChoices.options.find(function (option) {
|
|
139
|
+
return option.value === _this2._model.language;
|
|
140
|
+
})) {
|
|
141
|
+
this._configuration.languageChoices.options.push({
|
|
142
|
+
value: this._model.language,
|
|
143
|
+
label: this._model.language
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
} else {
|
|
147
|
+
delete this._model.language;
|
|
115
148
|
}
|
|
116
149
|
|
|
117
150
|
this._render();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.js"],"names":["log","DrawableResponseConfigure","m","reset","_model","dispatchModelUpdated","_render","c","_configuration","handler","dispatchEvent","InsertImageEvent","src","done","DeleteImageEvent","sensibleDefaults","configuration","withRubric","forceEnabled","settings","createDefaultModel","onModelChanged","bind","s","rubricEnabled","resetValue","ModelUpdatedEvent","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Root","model","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","render","HTMLElement","config","defaultModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEqBC,yB;;;;;AAgBnB,uCAAc;AAAA;;AAAA;;AAAA;AACZ;AADY,
|
|
1
|
+
{"version":3,"sources":["../src/index.js"],"names":["log","DrawableResponseConfigure","m","reset","_model","dispatchModelUpdated","_render","c","_configuration","handler","dispatchEvent","InsertImageEvent","src","done","DeleteImageEvent","sensibleDefaults","configuration","withRubric","forceEnabled","settings","createDefaultModel","onModelChanged","bind","s","rubricEnabled","language","enabled","languageChoices","options","length","value","find","option","push","label","resetValue","ModelUpdatedEvent","InsertSoundEvent","DeleteSoundEvent","element","React","createElement","Root","model","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","render","HTMLElement","config","defaultModel"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAQA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,mBAAN,CAAZ;;IAEqBC,yB;;;;;AAgBnB,uCAAc;AAAA;;AAAA;;AAAA;AACZ;AADY,uGAuEG,UAACC,CAAD,EAAIC,KAAJ,EAAc;AAC7B,YAAKC,MAAL,GAAcF,CAAd;;AACA,YAAKG,oBAAL,CAA0BF,KAA1B;;AACA,YAAKG,OAAL;AACD,KA3Ea;AAAA,+GA6EW,UAACC,CAAD,EAAO;AAC9B,YAAKC,cAAL,GAAsBD,CAAtB;;AAEA,YAAKD,OAAL;AACD,KAjFa;AAAA,oGAmFA,UAACG,OAAD,EAAa;AACzB,YAAKC,aAAL,CAAmB,IAAIC,oCAAJ,CAAqBF,OAArB,CAAnB;AACD,KArFa;AAAA,sGAuFE,UAACG,GAAD,EAAMC,IAAN,EAAe;AAC7B,YAAKH,aAAL,CAAmB,IAAII,oCAAJ,CAAqBF,GAArB,EAA0BC,IAA1B,CAAnB;AACD,KAzFa;AAEZ,UAAKL,cAAL,GAAsBO,qBAAiBC,aAAvC,CAFY,CAIZ;AACA;;AACA,iCAAI,MAAKR,cAAL,CAAoBS,UAAxB,kDAAI,sBAAgCC,YAApC,EAAkD;AAChD,YAAKV,cAAL,CAAoBS,UAApB,CAA+BE,QAA/B,GAA0C,KAA1C;AACD;;AAED,UAAKf,MAAL,GAAcH,yBAAyB,CAACmB,kBAA1B,CAA6C,EAA7C,EAAiD,MAAKZ,cAAtD,CAAd;AACA,UAAKa,cAAL,GAAsB,MAAKA,cAAL,CAAoBC,IAApB,gDAAtB;AAXY;AAYb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKnB,MAAL,GA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G,EAAE,KAAKC,WADE;AAEZ,oBAAQ,KAAKC;AAFD,SALwB;AAStCC,QAAAA,kBAAkB,EAAE;AAClBH,UAAAA,GAAG,EAAE,KAAKI,WAAL,CAAiB5B,IAAjB,CAAsB,IAAtB,CADa;AAElB,oBAAQ,KAAK6B,aAAL,CAAmB7B,IAAnB,CAAwB,IAAxB;AAFU;AATkB,OAA1B,CAAd;;AAcA8B,2BAASC,MAAT,CAAgBd,OAAhB,EAAyB,IAAzB;AACD;;;kDArIoDe,W;;;iCAAlCrD,yB,wBACS,YAAwB;AAAA;;AAAA,MAAvB0C,KAAuB,uEAAf,EAAe;AAAA,MAAXY,MAAW;;AAClD,MAAMC,YAAY,mCACbzC,qBAAiB4B,KADJ,GAEbA,KAFa,CAAlB,CADkD,CAMlD;AACA;;;AACA,MAAIY,MAAM,SAAN,IAAAA,MAAM,WAAN,0BAAAA,MAAM,CAAEtC,UAAR,kEAAoBC,YAApB,IAAoC,CAACsC,YAAY,CAAChC,aAAtD,EAAqE;AACnEgC,IAAAA,YAAY,CAAChC,aAAb,GAA6B,IAA7B;AACD;;AAED,SAAOgC,YAAP;AACD,C","sourcesContent":["import {\n DeleteImageEvent,\n DeleteSoundEvent,\n InsertImageEvent,\n InsertSoundEvent,\n ModelUpdatedEvent,\n} from '@pie-framework/pie-configure-events';\n\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport debug from 'debug';\n\nimport Root from './root';\nimport sensibleDefaults from './defaults';\n\nconst log = debug('hotspot:configure');\n\nexport default class DrawableResponseConfigure extends HTMLElement {\n static createDefaultModel = (model = {}, config) => {\n const defaultModel = {\n ...sensibleDefaults.model,\n ...model,\n };\n\n // if configuration.withRubric.forceEnabled is true, then we update the model\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._configuration = sensibleDefaults.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 = DrawableResponseConfigure.createDefaultModel({}, this._configuration);\n this.onModelChanged = this.onModelChanged.bind(this);\n }\n\n set model(s) {\n this._model = DrawableResponseConfigure.createDefaultModel(s, this._configuration);\n this._render();\n }\n\n set configuration(c) {\n this._configuration = c;\n\n const { withRubric = {} } = c || {};\n\n // if configuration.withRubric.forceEnabled is true, then we update the model\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 // if language:enabled is true, then the corresponding default item model should include a language value;\n // if it is false, then the language field should be omitted from the item model.\n // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,\n // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).\n if (c.language.enabled) {\n if (c.languageChoices?.options?.length) {\n this._model.language = c.languageChoices.options[0].value;\n }\n } else if (c.language.settings && this._model.language) {\n this._configuration.language.enabled = true;\n\n if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {\n this._configuration.languageChoices.options = [];\n }\n\n // check if the language is already included in the languageChoices.options array\n // and if not, then add it.\n if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {\n this._configuration.languageChoices.options.push({\n value: this._model.language,\n label: this._model.language,\n });\n }\n } else {\n delete this._model.language;\n }\n\n this._render();\n }\n\n dispatchModelUpdated(reset) {\n const resetValue = !!reset;\n\n this.dispatchEvent(new ModelUpdatedEvent(this._model, resetValue));\n }\n\n onModelChanged = (m, reset) => {\n this._model = m;\n this.dispatchModelUpdated(reset);\n this._render();\n };\n\n onConfigurationChanged = (c) => {\n this._configuration = c;\n\n this._render();\n };\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 log('_render');\n\n let element = React.createElement(Root, {\n model: this._model,\n configuration: this._configuration,\n onModelChanged: this.onModelChanged,\n onConfigurationChanged: this.onConfigurationChanged,\n imageSupport: {\n add: this.insertImage,\n delete: this.onDeleteImage,\n },\n uploadSoundSupport: {\n add: this.insertSound.bind(this),\n delete: this.onDeleteSound.bind(this),\n },\n });\n ReactDOM.render(element, this);\n }\n}\n"],"file":"index.js"}
|
package/configure/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
11
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
12
|
-
"@pie-lib/config-ui": "^11.
|
|
13
|
-
"@pie-lib/editable-html": "^9.7.
|
|
12
|
+
"@pie-lib/config-ui": "^11.9.1",
|
|
13
|
+
"@pie-lib/editable-html": "^9.7.5",
|
|
14
14
|
"classnames": "^2.2.6",
|
|
15
15
|
"debug": "^3.1.0",
|
|
16
16
|
"lodash": "^4.17.15",
|
package/configure/src/index.js
CHANGED
|
@@ -66,6 +66,32 @@ export default class DrawableResponseConfigure extends HTMLElement {
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
// if language:enabled is true, then the corresponding default item model should include a language value;
|
|
70
|
+
// if it is false, then the language field should be omitted from the item model.
|
|
71
|
+
// if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
|
|
72
|
+
// then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
|
|
73
|
+
if (c.language.enabled) {
|
|
74
|
+
if (c.languageChoices?.options?.length) {
|
|
75
|
+
this._model.language = c.languageChoices.options[0].value;
|
|
76
|
+
}
|
|
77
|
+
} else if (c.language.settings && this._model.language) {
|
|
78
|
+
this._configuration.language.enabled = true;
|
|
79
|
+
|
|
80
|
+
if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
|
|
81
|
+
this._configuration.languageChoices.options = [];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// check if the language is already included in the languageChoices.options array
|
|
85
|
+
// and if not, then add it.
|
|
86
|
+
if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
|
|
87
|
+
this._configuration.languageChoices.options.push({
|
|
88
|
+
value: this._model.language,
|
|
89
|
+
label: this._model.language,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
delete this._model.language;
|
|
94
|
+
}
|
|
69
95
|
|
|
70
96
|
this._render();
|
|
71
97
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/drawing-response",
|
|
3
|
-
"version": "6.5.3-next.
|
|
3
|
+
"version": "6.5.3-next.29+34b4dd7ba",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
14
14
|
"@pie-lib/math-rendering": "^2.5.17",
|
|
15
15
|
"@pie-lib/render-ui": "^4.14.29",
|
|
16
|
-
"@pie-lib/translator": "^2.
|
|
16
|
+
"@pie-lib/translator": "^2.2.0",
|
|
17
17
|
"classnames": "^2.2.6",
|
|
18
18
|
"enzyme-to-json": "^3.3.5",
|
|
19
19
|
"konva": "^3.4.1",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"author": "pie framework developers",
|
|
27
27
|
"license": "ISC",
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "34b4dd7ba18f4c18589975921cc9d127926f8294",
|
|
29
29
|
"scripts": {
|
|
30
30
|
"postpublish": "../../scripts/postpublish"
|
|
31
31
|
},
|