@oat-sa/tao-core-ui 3.8.0 → 3.8.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.
@@ -514,6 +514,7 @@ define(['jquery', 'nouislider', 'ui/resourcemgr', 'ui/tooltip', 'lodash', 'i18n'
514
514
  const figurelem = this.widget.element;
515
515
  const $texarea = this.widget.$form.find('textarea#figcaption');
516
516
  texareaHTMLElem = $texarea[0];
517
+ texareaHTMLElem.style.minHeight = '2em';
517
518
  function outputsize() {
518
519
  figurelem.data('heigthCaptionInput', $texarea.height());
519
520
  }
@@ -78,13 +78,16 @@ define(['exports', 'context', 'lodash'], function (exports, context, _) { 'use s
78
78
  if (!context.featureFlags['FEATURE_FLAG_DISABLE_FIGURE_WIDGET'] && prevClassName !== className) {
79
79
  // Re-build Figure widget to toggle between inline/block
80
80
  const parent = searchRecurse(widget.element.bdy.rootElement.bdy, widget.serial);
81
- // avoid changes on Figure in a prompt
82
- if (parent.contentModel && parent.contentModel === 'inlineStatic') {
81
+ // If Figure is not in A-block (Prompt, TextReader PCI)
82
+ if (parent.contentModel === 'inlineStatic' || widget.$container.closest('.qti-customInteraction').length) {
83
83
  _.defer(() => {
84
84
  widget.element.data('widget').refresh();
85
85
  });
86
86
  return;
87
87
  }
88
+ // If Figure is in A-block, text is inside '<p>'. When'<figure>' is added inside, this '<p>' tag gets split and a linebreak appears.
89
+ // here we change state to sleep-active so that the user will see that reflected in UI immediately.
90
+ // otherwise, he will see this linebreak only if he focuses text in this A-block again, or reopens the item.
88
91
  widget.element.data('widget').changeState('sleep');
89
92
  _.defer(() => {
90
93
  if (parent && parent.data('widget')) {
@@ -449,9 +449,16 @@ define(['jquery', 'lodash', 'i18n', 'core/eventifier', 'core/polling', 'core/dat
449
449
  if (!config.url || !config.url.download) {
450
450
  throw new TypeError('config.url.download is not configured while download() is being called');
451
451
  }
452
- return this.getCached(taskId).then(function (taskData) {
453
- let redirectUrl = (taskData || {}).redirectUrl;
454
- if (redirectUrl) {
452
+ return this.getCached(taskId).then(function () {
453
+ let taskData = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
454
+ const {
455
+ redirectUrl,
456
+ category
457
+ } = taskData;
458
+
459
+ // if the task is an update task, we should not use redirectUrl for download
460
+ // it only uses for DOCX file download (export category)
461
+ if (redirectUrl && category !== 'update') {
455
462
  return new Promise(function (resolve) {
456
463
  $.fileDownload(redirectUrl, {
457
464
  httpMethod: 'GET',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oat-sa/tao-core-ui",
3
- "version": "3.8.0",
3
+ "version": "3.8.2",
4
4
  "displayName": "TAO Core UI",
5
5
  "description": "UI libraries of TAO",
6
6
  "scripts": {
@@ -169,6 +169,7 @@ export default function ({ stateFactory, ActiveState, formTpl, formElement, inli
169
169
  const figurelem = this.widget.element;
170
170
  const $texarea = this.widget.$form.find('textarea#figcaption');
171
171
  texareaHTMLElem = $texarea[0];
172
+ texareaHTMLElem.style.minHeight = '2em';
172
173
  function outputsize() {
173
174
  figurelem.data('heigthCaptionInput', $texarea.height());
174
175
  }
@@ -82,13 +82,16 @@ export const positionFloat = function positionFloat(widget, position) {
82
82
  if (!context.featureFlags['FEATURE_FLAG_DISABLE_FIGURE_WIDGET'] && prevClassName !== className) {
83
83
  // Re-build Figure widget to toggle between inline/block
84
84
  const parent = searchRecurse(widget.element.bdy.rootElement.bdy, widget.serial);
85
- // avoid changes on Figure in a prompt
86
- if (parent.contentModel && parent.contentModel === 'inlineStatic') {
85
+ // If Figure is not in A-block (Prompt, TextReader PCI)
86
+ if (parent.contentModel === 'inlineStatic' || widget.$container.closest('.qti-customInteraction').length) {
87
87
  _.defer(() => {
88
88
  widget.element.data('widget').refresh();
89
89
  });
90
90
  return;
91
91
  }
92
+ // If Figure is in A-block, text is inside '<p>'. When'<figure>' is added inside, this '<p>' tag gets split and a linebreak appears.
93
+ // here we change state to sleep-active so that the user will see that reflected in UI immediately.
94
+ // otherwise, he will see this linebreak only if he focuses text in this A-block again, or reopens the item.
92
95
  widget.element.data('widget').changeState('sleep');
93
96
  _.defer(() => {
94
97
  if (parent && parent.data('widget')) {
@@ -496,10 +496,12 @@ export default function taskQueueModel(config) {
496
496
  throw new TypeError('config.url.download is not configured while download() is being called');
497
497
  }
498
498
 
499
- return this.getCached(taskId).then(function (taskData) {
500
- let redirectUrl = (taskData || {}).redirectUrl;
499
+ return this.getCached(taskId).then(function (taskData = {}) {
500
+ const { redirectUrl, category } = taskData;
501
501
 
502
- if (redirectUrl) {
502
+ // if the task is an update task, we should not use redirectUrl for download
503
+ // it only uses for DOCX file download (export category)
504
+ if (redirectUrl && category !== 'update') {
503
505
  return new Promise(function (resolve) {
504
506
  $.fileDownload(redirectUrl, {
505
507
  httpMethod: 'GET',