From abfc6bf4b1d1b069f6e016c5f26e049194229a6a Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 8 Mar 2024 16:31:30 -0500 Subject: [PATCH 1/2] Add syl after untoggle invalid syllables --- src/utils/EditControls.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/utils/EditControls.ts b/src/utils/EditControls.ts index ac6955ac..e83ceef2 100644 --- a/src/utils/EditControls.ts +++ b/src/utils/EditControls.ts @@ -340,6 +340,8 @@ export function initNavbar (neonView: NeonView): void { attrValue: '' } }); + + param.push(...addSylAction([syllable, precedesSyllable, followsSyllable])); } else if (syllable.hasAttribute('precedes')) { const precedesSyllable = syllables.find(element => element.getAttribute('xml:id') === syllable.getAttribute('precedes').substring(1)); @@ -373,6 +375,7 @@ export function initNavbar (neonView: NeonView): void { } }); } + param.push(...addSylAction([syllable, precedesSyllable])); } else if (syllable.hasAttribute('follows')) { const followsSyllable = syllables.find(element => element.getAttribute('xml:id') === syllable.getAttribute('follows').substring(1)); @@ -406,6 +409,7 @@ export function initNavbar (neonView: NeonView): void { } }); } + param.push(...addSylAction([syllable, followsSyllable])); } } @@ -517,3 +521,21 @@ export function initUndoRedoPanel (neonView: NeonView): void { } }); } + +function addSylAction(syllables: Element[]): Array { + const param = new Array(); + + for (const syllable of syllables) { + if (!syllable.getElementsByTagName('syl').length) { + param.push({ + action: 'setText', + param: { + elementId: syllable.getAttribute('xml:id'), + text: '', + } + }); + } + } + + return param; +} From 92a9b97d2d3bd1bcd77c61a6963e38492e51d473 Mon Sep 17 00:00:00 2001 From: Yinan Zhou Date: Fri, 8 Mar 2024 17:17:14 -0500 Subject: [PATCH 2/2] Fix highlight for precedes/follows sandwich --- src/utils/SelectTools.ts | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/utils/SelectTools.ts b/src/utils/SelectTools.ts index beadbaa9..fdad2550 100644 --- a/src/utils/SelectTools.ts +++ b/src/utils/SelectTools.ts @@ -568,15 +568,28 @@ export async function selectAll (elements: Array, neonView: groupsToSelect.add(grouping); // Check for precedes/follows - const follows = grouping.getAttribute('mei:follows'); - if (follows) { - document.querySelector('#' + follows.slice(1)).classList.add('no-moving'); - groupsToSelect.add(document.querySelector('#' + follows.slice(1))); - } - const precedes = grouping.getAttribute('mei:precedes'); - if (precedes) { - document.querySelector('#' + precedes.slice(1)).classList.add('no-moving'); - groupsToSelect.add(document.querySelector('#' + precedes.slice(1))); + let selected = grouping; + let follows = selected.getAttribute('mei:follows'); + let precedes = selected.getAttribute('mei:precedes'); + while (follows || precedes){ + if (follows) { + selected = document.querySelector('#' + follows.slice(1)); + if (groupsToSelect.has(selected)) { + break; + } + selected.classList.add('no-moving'); + groupsToSelect.add(selected); + follows = selected.getAttribute('mei:follows'); + } + if (precedes) { + selected = document.querySelector('#' + precedes.slice(1)); + if (groupsToSelect.has(selected)) { + break; + } + selected.classList.add('no-moving'); + groupsToSelect.add(selected); + precedes = selected.getAttribute('mei:precedes'); + } } } // Select the elements