Skip to content

Commit

Permalink
Merge pull request #477 from oat-sa/hotfix/BSA-370/rollback-inline-img
Browse files Browse the repository at this point in the history
Hotfix/bsa 370/rollback inline img
  • Loading branch information
shaveko authored Jun 23, 2023
2 parents 8d04f29 + ec7430d commit e727331
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 49 deletions.
2 changes: 1 addition & 1 deletion views/js/loader/taoMediaManager.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/js/loader/taoMediaManager.min.js.map

Large diffs are not rendered by default.

42 changes: 4 additions & 38 deletions views/js/qtiCreator/renderers/Img.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,16 @@
define([
'lodash',
'taoQtiItem/qtiCommonRenderer/renderers/Img',
'taoMediaManager/qtiCreator/widgets/static/img/Widget',
'taoQtiItem/qtiCreator/widgets/static/figure/Widget',
'taoQtiItem/qtiCreator/model/Figure',
'taoQtiItem/qtiCreator/helper/findParentElement'
], function (_, Renderer, Widget, FigureWidget, FigureModel, findParentElement) {
'taoMediaManager/qtiCreator/widgets/static/img/Widget'
], function (_, Renderer, Widget) {
'use strict';

const CreatorImg = _.clone(Renderer);

CreatorImg.render = function render(img, options) {
const $container = Renderer.getContainer(img);
if ($container.parent('figure').length || $container.parent('span').length && $container.parent('span').data('figure')) {
if ($container.parent('figure').length) {
// don't create widget if has figure parent
if (!$container.parent('figure').length && $container.siblings('figcaption').length) {
$container.siblings('figcaption').remove();
}
return CreatorImg;
}

Expand All @@ -45,35 +39,7 @@ define([
options.mediaManager = this.getOption('mediaManager');
options.assetManager = this.getAssetManager();

if (
!$container.closest('.qti-choice, .qti-flow-container').length &&
!$container.closest('.qti-table caption').length
) {
const parent = findParentElement(img.rootElement, img.serial);
parent.removeElement(img);
const figure = new FigureModel();
parent.setElement(figure);
const figureRenderer = parent.getRenderer();
if (figureRenderer) {
figure.setRenderer(figureRenderer);
figureRenderer.load(() => { }, ['figure']);
}
figure.setElement(img);
const $wrap = $container.wrap(`<span data-serial="${figure.serial}">`).parent();
FigureWidget.build(
figure,
$wrap,
this.getOption('bodyElementOptionForm'),
options
);
} else {
Widget.build(
img,
Renderer.getContainer(img),
this.getOption('bodyElementOptionForm'),
options
);
}
Widget.build(img, Renderer.getContainer(img), this.getOption('bodyElementOptionForm'), options);
};

return CreatorImg;
Expand Down
8 changes: 1 addition & 7 deletions views/js/qtiCreator/widgets/static/figure/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,7 @@ define([
};

FigureWidget.buildContainer = function buildContainer() {
if (this.element.attr('showFigure')) {
// If it is aligned to left or right, it will have FigCaption and will need Figure tag
helper.buildBlockContainer(this);
} else {
// On inline aligment, it must be an Image
helper.buildInlineContainer(this);
}
helper.buildBlockContainer(this);
const img = _.find(this.element.getBody().elements, elem => elem.is('img'));
const $img = this.$original.find('img');
if ($img.length) {
Expand Down
4 changes: 2 additions & 2 deletions views/js/qtiCreator/widgets/static/figure/states/Active.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ define([
'taoQtiItem/qtiCreator/widgets/helpers/formElement',
'taoQtiItem/qtiCreator/widgets/static/helpers/inline',
'ui/figure/FigureStateActive',
], function (stateFactory, ActiveState, formTpl, formElement, inlineHelper,FigureStateActive) {
], function (stateFactory, ActiveState, formTpl, formElement, inlineHelper, FigureStateActive) {
'use strict';
return FigureStateActive({ stateFactory, ActiveState, formTpl, formElement, inlineHelper });
return FigureStateActive(stateFactory, ActiveState, formTpl, formElement, inlineHelper);
});

0 comments on commit e727331

Please sign in to comment.