diff --git a/views/js/qtiCreator/widgets/helpers/selectionWrapper.js b/views/js/qtiCreator/widgets/helpers/selectionWrapper.js index 5d2beb53f3..fd8069c902 100644 --- a/views/js/qtiCreator/widgets/helpers/selectionWrapper.js +++ b/views/js/qtiCreator/widgets/helpers/selectionWrapper.js @@ -134,10 +134,10 @@ define(['jquery'], function ($) { * @param {jQuery} $wrapper - the element that will wrap the selection * @returns {boolean} */ - wrapWith: function wrapWith($wrapper) { - const range = selection.getRangeAt(0); + wrapWith: function wrapWith($wrapper, providedRange) { + const range = providedRange || selection.getRangeAt(0); - if (this.canWrap()) { + if (this.canWrap(range)) { try { range.surroundContents($wrapper[0]); selection.removeAllRanges(); diff --git a/views/js/qtiCreator/widgets/interactions/hottextInteraction/states/Question.js b/views/js/qtiCreator/widgets/interactions/hottextInteraction/states/Question.js index cba54c2b72..ccaac9e658 100755 --- a/views/js/qtiCreator/widgets/interactions/hottextInteraction/states/Question.js +++ b/views/js/qtiCreator/widgets/interactions/hottextInteraction/states/Question.js @@ -140,7 +140,7 @@ define([ } else { if ( $cloneContent.text() === $cloneContent.html() && - wrapper.wrapWith($newHottextClone) + wrapper.wrapWith($newHottextClone, range) ) { await this.createNewHottext($newHottextClone); } else {