From fd8e3c8b0a1656e54561781c7fdb5ceb22b9fd80 Mon Sep 17 00:00:00 2001 From: lecosson Date: Thu, 26 Dec 2019 10:27:32 +0300 Subject: [PATCH 1/2] fixed new string value on clipboard paste https://oat-sa.atlassian.net/browse/TAO-9922 WTP-1493 [ACT] - On writing item, text is always pasted to the end. --- package.json | 2 +- .../interactions/ExtendedTextInteraction.js | 23 ++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 046127ed..ec5a22b1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@oat-sa/tao-item-runner-qti", - "version": "0.4.12", + "version": "0.4.13", "displayName": "TAO Item Runner QTI", "description": "TAO QTI Item Runner modules", "files": [ diff --git a/src/qtiCommonRenderer/renderers/interactions/ExtendedTextInteraction.js b/src/qtiCommonRenderer/renderers/interactions/ExtendedTextInteraction.js index 0eada2c4..621c23ae 100644 --- a/src/qtiCommonRenderer/renderers/interactions/ExtendedTextInteraction.js +++ b/src/qtiCommonRenderer/renderers/interactions/ExtendedTextInteraction.js @@ -496,8 +496,8 @@ var inputLimiter = function userInputLimier(interaction) { newValue = e.originalEvent.clipboardData ? e.originalEvent.clipboardData.getData('text') : e.originalEvent.dataTransfer.getData('text') || - e.originalEvent.dataTransfer.getData('text/plain') || - ''; + e.originalEvent.dataTransfer.getData('text/plain') || + ''; } // prevent insertion of non-limited data @@ -523,10 +523,21 @@ var inputLimiter = function userInputLimier(interaction) { if (isCke) { _getCKEditor(interaction).insertHtml(newValue); } else { - containerHelper - .get(interaction) - .find('textarea') - .val(oldValue + newValue); + let elements = containerHelper.get(interaction).find('textarea'); + let el = elements[0]; + let { + selectionStart: start, + selectionEnd: end, + value: text + } = el; + elements.val( + text.substring(0, start) + + newValue + + text.substring(end, text.length) + ); + el.focus(); + el.selectionStart = start + newValue.length; + el.selectionEnd = el.selectionStart; } _.defer(function() { From 89ca8a6933a72154b3c6841dd9f678a8728e1f61 Mon Sep 17 00:00:00 2001 From: lecosson Date: Fri, 27 Dec 2019 14:12:16 +0300 Subject: [PATCH 2/2] fixed new string value on clipboard paste https://oat-sa.atlassian.net/browse/TAO-9922 WTP-1493 [ACT] - On writing item, text is always pasted to the end. --- package-lock.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 39030b71..229292d0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@oat-sa/tao-item-runner-qti", - "version": "0.4.12", + "version": "0.4.13", "lockfileVersion": 1, "requires": true, "dependencies": {