You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@answer.apache.org by ro...@apache.org on 2024/09/20 03:13:34 UTC

(incubator-answer-plugins) branch main updated (0dfaa3d -> aeec516)

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

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


    from 0dfaa3d  refactor(highlight): Add Apache License header to theme_list.go (#225)
     new f6677e1  refactor(highlight): Improve useHighlightCode function
     new 581938b  refactor(render-markdown-codehighlight): Update version to 0.0.4
     new aeec516  chore: Sync Plugin Info (#226)

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 render-markdown-codehighlight/hooks.ts     | 18 +++++++++++++-----
 render-markdown-codehighlight/info.yaml    |  2 +-
 render-markdown-codehighlight/package.json |  2 +-
 3 files changed, 15 insertions(+), 7 deletions(-)


(incubator-answer-plugins) 01/03: refactor(highlight): Improve useHighlightCode function

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit f6677e140637cdf0da4a96ea0dde46dfeaecb28e
Author: robin <ro...@rnode.me>
AuthorDate: Fri Sep 20 11:11:48 2024 +0800

    refactor(highlight): Improve useHighlightCode function
---
 render-markdown-codehighlight/hooks.ts | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/render-markdown-codehighlight/hooks.ts b/render-markdown-codehighlight/hooks.ts
index 99bf52a..1cec680 100644
--- a/render-markdown-codehighlight/hooks.ts
+++ b/render-markdown-codehighlight/hooks.ts
@@ -19,10 +19,12 @@
 
 import { useEffect, useState } from 'react';
 import hljs from 'highlight.js';
-import { themeStyles } from './themeStyles'
+import { themeStyles } from './themeStyles';
 
 
-const useHighlightCode = (element: HTMLElement | null) => {
+const useHighlightCode = (props: HTMLElement | null | {
+  current: HTMLElement | null;
+}) => {
   const [selectTheme, setSelectTheme] = useState<string>('default');
 
   // Fetch theme from API
@@ -39,7 +41,14 @@ const useHighlightCode = (element: HTMLElement | null) => {
   }, []);
 
   useEffect(() => {
-    if (!element) return;
+    let element;
+    if (props instanceof HTMLElement) {
+      element = props;
+    } else if (props && props.current instanceof HTMLElement) {
+      element = props.current;
+    } else {
+      return;
+    }
 
     const applyThemeCSS = async (theme: string) => {
       const existingStyleElement = document.querySelector('style[data-theme-style="highlight"]');
@@ -96,10 +105,9 @@ const useHighlightCode = (element: HTMLElement | null) => {
       contentObserver.disconnect();
       themeObserver.disconnect();
     };
-  }, [element, selectTheme]);
+  }, [props, selectTheme]);
 
   return null;
 };
 
 export { useHighlightCode };
-


(incubator-answer-plugins) 03/03: chore: Sync Plugin Info (#226)

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit aeec5165a11fbded7f48bc976cc8f14ca5e5b058
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Fri Sep 20 11:12:57 2024 +0800

    chore: Sync Plugin Info (#226)
    
    Sync Plugin Info
    
    Co-authored-by: robinv8 <ro...@users.noreply.github.com>
---
 render-markdown-codehighlight/package.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/render-markdown-codehighlight/package.json b/render-markdown-codehighlight/package.json
index 147088a..1f5d228 100644
--- a/render-markdown-codehighlight/package.json
+++ b/render-markdown-codehighlight/package.json
@@ -1,6 +1,6 @@
 {
   "name": "render-markdown-codehighlight",
-  "version": "0.0.3",
+  "version": "0.0.4",
   "description": "",
   "type": "module",
   "files": [


(incubator-answer-plugins) 02/03: refactor(render-markdown-codehighlight): Update version to 0.0.4

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 581938b9e97df3d232f5885c8bf4b6483ee41aa5
Author: robin <ro...@rnode.me>
AuthorDate: Fri Sep 20 11:12:10 2024 +0800

    refactor(render-markdown-codehighlight): Update version to 0.0.4
---
 render-markdown-codehighlight/info.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/render-markdown-codehighlight/info.yaml b/render-markdown-codehighlight/info.yaml
index 10cdb8f..b6fa9a9 100644
--- a/render-markdown-codehighlight/info.yaml
+++ b/render-markdown-codehighlight/info.yaml
@@ -17,6 +17,6 @@
 
 slug_name: render_markdown_codehighlight
 type: render
-version: 0.0.3
+version: 0.0.4
 author: Chen Jiaji, Zhu Xuanlyu
 link: https://github.com/apache/incubator-answer-plugins/tree/main/render-markdown-codehighlight