From 1bc81c15a01065f36f559a76bf2fd9c47db36ae7 Mon Sep 17 00:00:00 2001
From: Mike Feranda <26969-mferanda@users.noreply.drupalcode.org>
Date: Sat, 14 Sep 2024 13:12:55 +0000
Subject: [PATCH] Issue #3474361 by mferanda: AIDmi button conflicting with
 link

---
 js/aidmi_ckeditor.js | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/js/aidmi_ckeditor.js b/js/aidmi_ckeditor.js
index cf2d9cd..a8f14eb 100644
--- a/js/aidmi_ckeditor.js
+++ b/js/aidmi_ckeditor.js
@@ -65,8 +65,11 @@ let aidmiEditedText;
                 existingButton.focus();
               }
               altTextField = mutation.target;
+              // Check if the alternative text form exists.
+              altTextForm = document.querySelector('.ck-text-alternative-form');
+              // Get the selected image.
               imgTag = aidmiActiveEditorInstance.data.stringify(aidmiActiveEditorInstance.model.getSelectedContent(aidmiActiveEditorInstance.model.document.selection));
-              if (altTextField) {
+              if ((altTextForm) && (altTextField) && (imgTag)) {
                 aidmiButton(altTextField, aidmiActiveEditorInstance, imgTag);
               }
             }
-- 
GitLab