Update image-modifiers.js

Reloading of image tags with ((weight modifiers)) doesn't reuse the modifier card even if it exists, which means images are not restored either. This change fixes that behavior by ensuring proper matching of the tags with existing modifiers.
This commit is contained in:
patriceac 2023-02-22 00:57:03 -08:00 committed by GitHub
parent 1b4c14af71
commit 14118f142c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -167,12 +167,14 @@ function refreshModifiersState(newTags) {
let found = false
document.querySelector('#editor-modifiers').querySelectorAll('.modifier-card').forEach(modifierCard => {
const modifierName = modifierCard.querySelector('.modifier-card-label').innerText
if (tag == modifierName) {
if (trimModifiers(tag) == trimModifiers(modifierName)) {
// add modifier to active array
if (!activeTags.map(x => x.name).includes(tag)) { // only add each tag once even if several custom modifier cards share the same tag
const imageModifierCard = modifierCard.cloneNode(true)
imageModifierCard.querySelector('.modifier-card-label p').innerText = tag
activeTags.push({
'name': modifierName,
'element': modifierCard.cloneNode(true),
'element': imageModifierCard,
'originElement': modifierCard
})
}