@pie-element/match 7.2.2-next.0 → 7.2.2-next.2

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.
@@ -60,6 +60,16 @@ var MatchConfigure = /*#__PURE__*/function (_HTMLElement) {
60
60
  (0, _classCallCheck2["default"])(this, MatchConfigure);
61
61
  _this = _super.call(this);
62
62
  (0, _defineProperty2["default"])((0, _assertThisInitialized2["default"])(_this), "resetModelAfterConfigurationIsSet", function () {
63
+ // In environments that use pie-player-components, model is set before configuration.
64
+ // This is the reason why sometimes the model gets altered non-reversible
65
+ // (altered using default configuration instead of client configuration, because at that point client configuration was not set yet)
66
+ // Therefore, in such environments, we will make sure to keep a modelCopy (initialised in set model) and use it to reset
67
+ // the model in set configuration (resetModelAfterConfigurationIsSet) if set configuration is ever called
68
+ var pieAuthors = document.querySelectorAll('pie-author');
69
+ _this.hasPlayerAsParent = Array.from(pieAuthors).some(function (author) {
70
+ return author.contains((0, _assertThisInitialized2["default"])(_this));
71
+ });
72
+
63
73
  if (_this.hasPlayerAsParent) {
64
74
  if (_this._modelCopy) {
65
75
  _this._model = _this._modelCopy;
@@ -69,16 +79,7 @@ var MatchConfigure = /*#__PURE__*/function (_HTMLElement) {
69
79
  }
70
80
  });
71
81
  _this._model = MatchConfigure.createDefaultModel();
72
- _this._configuration = _defaults["default"].configuration; // In environments that use pie-player-components, model is set before configuration.
73
- // This is the reason why sometimes the model gets altered non-reversible
74
- // (altered using default configuration instead of client configuration, because at that point client configuration was not set yet)
75
- // Therefore, in such environments, we will make sure to keep a modelCopy (initialised in set model) and use it to reset
76
- // the model in set configuration (resetModelAfterConfigurationIsSet) if set configuration is ever called
77
-
78
- var pieAuthors = document.querySelectorAll('pie-author');
79
- _this.hasPlayerAsParent = Array.from(pieAuthors).some(function (author) {
80
- return author.contains((0, _assertThisInitialized2["default"])(_this));
81
- });
82
+ _this._configuration = _defaults["default"].configuration;
82
83
  return _this;
83
84
  }
84
85
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.js"],"names":["log","MatchConfigure","hasPlayerAsParent","_modelCopy","_model","createDefaultModel","_configuration","defaultValues","configuration","pieAuthors","document","querySelectorAll","Array","from","some","author","contains","m","_render","c","newConfiguration","resetModelAfterConfigurationIsSet","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","rows","inputConfiguration","enableImages","model","dispatchEvent","ModelUpdatedEvent","config","handler","InsertImageEvent","src","done","DeleteImageEvent","InsertSoundEvent","DeleteSoundEvent","el","React","createElement","Configure","onModelChanged","bind","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","render","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,8BAAN,CAAZ;;IAEqBC,c;;;;;AAMnB,4BAAc;AAAA;;AAAA;AACZ;AADY,0HAqBsB,YAAM;AACxC,UAAI,MAAKC,iBAAT,EAA4B;AAC1B,YAAI,MAAKC,UAAT,EAAqB;AACnB,gBAAKC,MAAL,GAAc,MAAKD,UAAnB;AACD,SAFD,MAEO;AACL,iBAAO,MAAKA,UAAZ;AACD;AACF;AACF,KA7Ba;AAEZ,UAAKC,MAAL,GAAcH,cAAc,CAACI,kBAAf,EAAd;AACA,UAAKC,cAAL,GAAsBC,qBAAcC,aAApC,CAHY,CAKZ;AACA;AACA;AACA;AACA;;AACA,QAAMC,UAAU,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,YAA1B,CAAnB;AACA,UAAKT,iBAAL,GAAyBU,KAAK,CAACC,IAAN,CAAWJ,UAAX,EAAuBK,IAAvB,CAA4B,UAACC,MAAD;AAAA,aAAYA,MAAM,CAACC,QAAP,gDAAZ;AAAA,KAA5B,CAAzB;AAXY;AAYb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKb,MAAL,GAA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KAFuB;AAAA,C","sourcesContent":["import { isEmpty, set } from 'lodash';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport Configure from './configure';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\nimport debug from 'debug';\nimport defaultValues from './defaults';\nimport cloneDeep from 'lodash/cloneDeep';\n\nconst log = debug('pie-elements:match:configure');\n\nexport default class MatchConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...defaultValues.model,\n ...model,\n });\n\n constructor() {\n super();\n this._model = MatchConfigure.createDefaultModel();\n this._configuration = defaultValues.configuration;\n\n // In environments that use pie-player-components, model is set before configuration.\n // This is the reason why sometimes the model gets altered non-reversible\n // (altered using default configuration instead of client configuration, because at that point client configuration was not set yet)\n // Therefore, in such environments, we will make sure to keep a modelCopy (initialised in set model) and use it to reset\n // the model in set configuration (resetModelAfterConfigurationIsSet) if set configuration is ever called\n const pieAuthors = document.querySelectorAll('pie-author');\n this.hasPlayerAsParent = Array.from(pieAuthors).some((author) => author.contains(this));\n }\n\n set model(m) {\n this._model = MatchConfigure.createDefaultModel(m);\n this._modelCopy = cloneDeep(this._model);\n\n this._render();\n }\n\n resetModelAfterConfigurationIsSet = () => {\n if (this.hasPlayerAsParent) {\n if (this._modelCopy) {\n this._model = this._modelCopy;\n } else {\n delete this._modelCopy;\n }\n }\n };\n\n set configuration(c) {\n const newConfiguration = {\n ...defaultValues.configuration,\n ...c,\n };\n\n this._configuration = newConfiguration;\n\n this.resetModelAfterConfigurationIsSet();\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 (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.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 /**\n * @Deprecated we added rows.inputConfiguration to handle the plugins in the editable html fields\n * if rows.inputConfiguration we try to default to the old enableImages flag\n * This flag 'enableImages' will be removed in the future\n */\n if (isEmpty(!c?.rows?.inputConfiguration)) {\n set(this._configuration.rows, 'inputConfiguration.image.disabled', !this._model?.enableImages);\n set(this._configuration.rows, 'inputConfiguration.video.disabled', true);\n set(this._configuration.rows, 'inputConfiguration.audio.disabled', true);\n }\n\n this._render();\n }\n\n onModelChanged(model) {\n this._model = model;\n log('[onModelChanged]: ', this._model);\n this._render();\n this.dispatchEvent(new ModelUpdatedEvent(this._model));\n }\n\n onConfigurationChanged(config) {\n this._configuration = config;\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 el = React.createElement(Configure, {\n onModelChanged: this.onModelChanged.bind(this),\n onConfigurationChanged: this.onConfigurationChanged.bind(this),\n model: this._model,\n configuration: this._configuration,\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 ReactDOM.render(el, this);\n }\n }\n}\n"],"file":"index.js"}
1
+ {"version":3,"sources":["../src/index.js"],"names":["log","MatchConfigure","pieAuthors","document","querySelectorAll","hasPlayerAsParent","Array","from","some","author","contains","_modelCopy","_model","createDefaultModel","_configuration","defaultValues","configuration","m","_render","c","newConfiguration","resetModelAfterConfigurationIsSet","language","enabled","languageChoices","options","length","value","settings","find","option","push","label","rows","inputConfiguration","enableImages","model","dispatchEvent","ModelUpdatedEvent","config","handler","InsertImageEvent","src","done","DeleteImageEvent","InsertSoundEvent","DeleteSoundEvent","el","React","createElement","Configure","onModelChanged","bind","onConfigurationChanged","imageSupport","add","insertImage","onDeleteImage","uploadSoundSupport","insertSound","onDeleteSound","ReactDOM","render","HTMLElement"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAOA;;AACA;;AACA;;;;;;;;;;AAEA,IAAMA,GAAG,GAAG,uBAAM,8BAAN,CAAZ;;IAEqBC,c;;;;;AAMnB,4BAAc;AAAA;;AAAA;AACZ;AADY,0HAasB,YAAM;AACxC;AACA;AACA;AACA;AACA;AACA,UAAMC,UAAU,GAAGC,QAAQ,CAACC,gBAAT,CAA0B,YAA1B,CAAnB;AACA,YAAKC,iBAAL,GAAyBC,KAAK,CAACC,IAAN,CAAWL,UAAX,EAAuBM,IAAvB,CAA4B,UAACC,MAAD;AAAA,eAAYA,MAAM,CAACC,QAAP,gDAAZ;AAAA,OAA5B,CAAzB;;AAEA,UAAI,MAAKL,iBAAT,EAA4B;AAC1B,YAAI,MAAKM,UAAT,EAAqB;AACnB,gBAAKC,MAAL,GAAc,MAAKD,UAAnB;AACD,SAFD,MAEO;AACL,iBAAO,MAAKA,UAAZ;AACD;AACF;AACF,KA7Ba;AAEZ,UAAKC,MAAL,GAAcX,cAAc,CAACY,kBAAf,EAAd;AACA,UAAKC,cAAL,GAAsBC,qBAAcC,aAApC;AAHY;AAIb;;;;SAED,aAAUC,CAAV,EAAa;AACX,WAAKL,M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ourcesContent":["import { isEmpty, set } from 'lodash';\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport Configure from './configure';\nimport {\n ModelUpdatedEvent,\n DeleteImageEvent,\n InsertImageEvent,\n InsertSoundEvent,\n DeleteSoundEvent,\n} from '@pie-framework/pie-configure-events';\nimport debug from 'debug';\nimport defaultValues from './defaults';\nimport cloneDeep from 'lodash/cloneDeep';\n\nconst log = debug('pie-elements:match:configure');\n\nexport default class MatchConfigure extends HTMLElement {\n static createDefaultModel = (model = {}) => ({\n ...defaultValues.model,\n ...model,\n });\n\n constructor() {\n super();\n this._model = MatchConfigure.createDefaultModel();\n this._configuration = defaultValues.configuration;\n }\n\n set model(m) {\n this._model = MatchConfigure.createDefaultModel(m);\n this._modelCopy = cloneDeep(this._model);\n\n this._render();\n }\n\n resetModelAfterConfigurationIsSet = () => {\n // In environments that use pie-player-components, model is set before configuration.\n // This is the reason why sometimes the model gets altered non-reversible\n // (altered using default configuration instead of client configuration, because at that point client configuration was not set yet)\n // Therefore, in such environments, we will make sure to keep a modelCopy (initialised in set model) and use it to reset\n // the model in set configuration (resetModelAfterConfigurationIsSet) if set configuration is ever called\n const pieAuthors = document.querySelectorAll('pie-author');\n this.hasPlayerAsParent = Array.from(pieAuthors).some((author) => author.contains(this));\n\n if (this.hasPlayerAsParent) {\n if (this._modelCopy) {\n this._model = this._modelCopy;\n } else {\n delete this._modelCopy;\n }\n }\n };\n\n set configuration(c) {\n const newConfiguration = {\n ...defaultValues.configuration,\n ...c,\n };\n\n this._configuration = newConfiguration;\n\n this.resetModelAfterConfigurationIsSet();\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 (newConfiguration?.language?.enabled) {\n if (newConfiguration?.languageChoices?.options?.length) {\n this._model.language = newConfiguration?.languageChoices.options[0].value;\n }\n } else if (newConfiguration.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 /**\n * @Deprecated we added rows.inputConfiguration to handle the plugins in the editable html fields\n * if rows.inputConfiguration we try to default to the old enableImages flag\n * This flag 'enableImages' will be removed in the future\n */\n if (isEmpty(!c?.rows?.inputConfiguration)) {\n set(this._configuration.rows, 'inputConfiguration.image.disabled', !this._model?.enableImages);\n set(this._configuration.rows, 'inputConfiguration.video.disabled', true);\n set(this._configuration.rows, 'inputConfiguration.audio.disabled', true);\n }\n\n this._render();\n }\n\n onModelChanged(model) {\n this._model = model;\n log('[onModelChanged]: ', this._model);\n this._render();\n this.dispatchEvent(new ModelUpdatedEvent(this._model));\n }\n\n onConfigurationChanged(config) {\n this._configuration = config;\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 el = React.createElement(Configure, {\n onModelChanged: this.onModelChanged.bind(this),\n onConfigurationChanged: this.onConfigurationChanged.bind(this),\n model: this._model,\n configuration: this._configuration,\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 ReactDOM.render(el, this);\n }\n }\n}\n"],"file":"index.js"}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public"
5
5
  },
6
6
  "repository": "pie-framework/pie-elements",
7
- "version": "7.2.2-next.0+e889ff0c6",
7
+ "version": "7.2.2-next.2+06066f4f8",
8
8
  "main": "lib/index.js",
9
9
  "description": "",
10
10
  "scripts": {
@@ -23,6 +23,6 @@
23
23
  },
24
24
  "author": "",
25
25
  "license": "ISC",
26
- "gitHead": "e889ff0c6629389ee7d431395f377727bce9dc92",
26
+ "gitHead": "06066f4f8746ca1cde10ea81a4dd791fb008063e",
27
27
  "module": "src/index.js"
28
28
  }