From ec0b746026cf05e25a7d8e7e995e35c86ccb9528 Mon Sep 17 00:00:00 2001 From: jojohoch <joachim.hoch@iqb.hu-berlin.de> Date: Mon, 10 Jan 2022 12:22:23 +0100 Subject: [PATCH] [player] Fix marking text when the selection is empty at the end --- docs/release-notes-player.txt | 2 +- .../player/src/app/services/marking.service.ts | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/release-notes-player.txt b/docs/release-notes-player.txt index 90fa9d9af..d8860d84d 100644 --- a/docs/release-notes-player.txt +++ b/docs/release-notes-player.txt @@ -2,9 +2,9 @@ Player ====== 1.14.1 - Fix restoring of toggle buttons +- Fix marking text when the selection is empty at the end - Improve checking of responsesProgress of compound elements - 1.14.0 - Specify the colors for marking in hexadecimal notation - Improve the determination of the ResponseProgress diff --git a/projects/player/src/app/services/marking.service.ts b/projects/player/src/app/services/marking.service.ts index 6bcdcfa54..aeb46bf1d 100644 --- a/projects/player/src/app/services/marking.service.ts +++ b/projects/player/src/app/services/marking.service.ts @@ -128,9 +128,13 @@ export class MarkingService { } private addEndContainer = (nodes: Node[], endContainer: Node): void => { - if (endContainer.nodeType === Node.ELEMENT_NODE && endContainer.childNodes.length) { - if (!nodes.includes(endContainer.childNodes[0])) { - nodes.push(endContainer.childNodes[0]); + if (endContainer.nodeType === Node.ELEMENT_NODE) { + if (endContainer.childNodes.length) { + if (!nodes.includes(endContainer.childNodes[0])) { + nodes.push(endContainer.childNodes[0]); + } + } else if (!nodes.includes(endContainer)) { + nodes.push(endContainer); } } else if (endContainer.nodeType === Node.TEXT_NODE) { nodes.push(endContainer); @@ -249,8 +253,10 @@ export class MarkingService { nodes.push(node); } if (node.nodeType === Node.ELEMENT_NODE) { - if (node.childNodes) { + if (node.childNodes.length) { this.findNodes(node.childNodes, nodes, selection); + } else if (!nodes.includes(node)) { + nodes.push(node); } } } -- GitLab