Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/aut 3923/textreader image figure support #2613

Merged
merged 7 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion views/css/item-creator.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion views/css/item-creator.css.map

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions views/js/qtiCreator/editor/ckEditor/htmlEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ define([
'taoQtiItem/qtiCreator/widgets/helpers/content',
'taoQtiItem/qtiCreator/widgets/helpers/deletingState',
'taoQtiItem/qtiCreator/editor/ckEditor/featureFlag',
'taoQtiItem/qtiCreator/helper/languages'
'taoQtiItem/qtiCreator/helper/languages',
'taoQtiItem/qtiCreator/helper/elementSupport',
], function (
_,
__,
Expand All @@ -40,7 +41,8 @@ define([
contentHelper,
deletingHelper,
featureFlag,
languages
languages,
elementSupportHelper
) {
'use strict';

Expand Down Expand Up @@ -133,8 +135,7 @@ define([
const $newImgPlaceholder = $editable.find('[data-new="true"][data-qti-class="img"]');
if (
$newImgPlaceholder.length &&
!$editable.closest('.qti-choice, .qti-flow-container').length &&
!$newImgPlaceholder.closest('.qti-table caption').length
elementSupportHelper.isFigureSupportedInParent($newImgPlaceholder)
) {
// instead img will add figure element
$newImgPlaceholder.attr('data-qti-class', 'figure');
Expand Down
42 changes: 42 additions & 0 deletions views/js/qtiCreator/helper/elementSupport.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; under version 2
* of the License (non-upgradable).
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* Copyright (c) 2024 (original work) Open Assessment Technologies SA ;
*/

define([], function () {
'use strict';

/**
* Before inserting Figure widget, check if parent element supports it.
* If supported, image wrap will be implemented as `<figure class="wrap-right"><img></figure>`.
* If not supported, image wrap will be implemented as `<img class="wrap-right">`
* @param {JQuery} $container
* @returns {boolean}
*/
const isFigureSupportedInParent = ($container) => {
const notSupported = (
$container.closest('.qti-choice, .qti-flow-container').length ||
$container.closest('.qti-table caption').length ||
$container.closest('.qti-modalFeedback').length ||
($container.closest('.qti-customInteraction').length && !$container.closest('[data-element-support-figure="true"]').length)
);
return !notSupported;
};

return {
isFigureSupportedInParent
};
});
9 changes: 4 additions & 5 deletions views/js/qtiCreator/renderers/Img.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ define([
'taoQtiItem/qtiCreator/widgets/static/img/Widget',
'taoQtiItem/qtiCreator/widgets/static/figure/Widget',
'taoQtiItem/qtiCreator/model/Figure',
'taoQtiItem/qtiCreator/helper/findParentElement'
], function (_, context, Renderer, Widget, FigureWidget, FigureModel, findParentElement) {
'taoQtiItem/qtiCreator/helper/findParentElement',
'taoQtiItem/qtiCreator/helper/elementSupport',
], function (_, context, Renderer, Widget, FigureWidget, FigureModel, findParentElement, elementSupportHelper) {
'use strict';

const CreatorImg = _.clone(Renderer);
Expand Down Expand Up @@ -59,9 +60,7 @@ define([

if (
!DISABLE_FIGURE_WIDGET &&
!$container.closest('.qti-choice, .qti-flow-container').length &&
!$container.closest('.qti-table caption').length &&
!$container.closest('.qti-modalFeedback').length
elementSupportHelper.isFigureSupportedInParent($container)
) {
const parent = findParentElement(img.rootElement, img.serial);
parent.removeElement(img);
Expand Down
3 changes: 3 additions & 0 deletions views/js/qtiCreator/widgets/static/figure/Widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ define([
$img.attr('width', '100%');
$img.removeAttr('style');
}

this.$container.attr('contenteditable', false); //case: textReaderInteraction PCI

return this;
};

Expand Down
3 changes: 3 additions & 0 deletions views/scss/item-creator.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,9 @@ img.dragging.ui-draggable-dragging {
display: flex;
}
}
.cke_editable {
clear: both;
}
}
.qti-interaction {
.add-option {
Expand Down
Loading