This is an automated email from the ASF dual-hosted git repository.

robin0716 pushed a commit to branch feat/embed
in repository https://gitbox.apache.org/repos/asf/incubator-answer-plugins.git


The following commit(s) were added to refs/heads/feat/embed by this push:
     new 7e971db  refactor(embed-basic): Improve rendering of embeds by using 
parentElement instead of link
7e971db is described below

commit 7e971dbe300335e4046e6272ad9e8149ae3cd0aa
Author: robin <[email protected]>
AuthorDate: Thu Jun 6 18:33:01 2024 +0800

    refactor(embed-basic): Improve rendering of embeds by using parentElement 
instead of link
---
 embed-basic/hooks.ts | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/embed-basic/hooks.ts b/embed-basic/hooks.ts
index fd88f02..9380f88 100644
--- a/embed-basic/hooks.ts
+++ b/embed-basic/hooks.ts
@@ -194,22 +194,23 @@ const useRenderEmbed = (
       }
       const embed = renderEmbed(url, link?.textContent || '');
       if (embed) {
+        const parentElement = link.parentElement as HTMLElement;
         if (typeof embed === 'string') {
-          link.innerHTML = embed;
+          parentElement.innerHTML = embed;
         } else if (Array.isArray(embed)) {
-          link.innerHTML = '';
+          link.remove();
           embed.forEach((item) => {
-            link.appendChild(item);
+            parentElement.appendChild(item);
           });
         } else {
           link.innerHTML = '';
-          link.appendChild(embed);
+          parentElement.appendChild(embed);
         }
       } else {
         link.innerHTML = `
           <div class="border rounded p-3">
-            <div class="text-secondary">${url}</div>
-            <div class="text-body">${link.textContent}</div>
+            <div class="text-secondary small mb-1">${url}</div>
+            <div class="text-body fw-bold">${link.textContent}</div>
           </div>
         `;
       }

Reply via email to