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/11/13 04:04:02 UTC

(incubator-answer-plugins) branch main updated (9d64467 -> b9b677f)

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 9d64467  fix: bump version to 1.2.12 in info.yaml
     new 277b743  refactor(embed-basic): Update useRenderEmbed hook to accept a request object
     new 74baae3  refactor(render-markdown-codehighlight): Update useHighlightCode hook to accept a request object
     new 5a55435  refactor: Code to add Apache License header
     new b9b677f  chore: Update version in info.yaml files

The 4 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:
 embed-basic/hooks.tsx                                        | 11 ++++++-----
 embed-basic/info.yaml                                        |  2 +-
 captcha-basic/Captcha.tsx => embed-basic/types.ts            | 12 ++++++------
 render-markdown-codehighlight/hooks.ts                       | 10 ++++++----
 render-markdown-codehighlight/info.yaml                      |  2 +-
 .../Captcha.tsx => render-markdown-codehighlight/types.ts    | 12 ++++++------
 6 files changed, 26 insertions(+), 23 deletions(-)
 copy captcha-basic/Captcha.tsx => embed-basic/types.ts (81%)
 copy captcha-basic/Captcha.tsx => render-markdown-codehighlight/types.ts (81%)


(incubator-answer-plugins) 02/04: refactor(render-markdown-codehighlight): Update useHighlightCode hook to accept a request object

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 74baae3cb7b211da039e2f2047aa2e7ef027a640
Author: robin <ro...@rnode.me>
AuthorDate: Wed Sep 25 16:40:48 2024 +0800

    refactor(render-markdown-codehighlight): Update useHighlightCode hook to accept a request object
---
 render-markdown-codehighlight/hooks.ts | 10 ++++++----
 render-markdown-codehighlight/types.ts |  7 +++++++
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/render-markdown-codehighlight/hooks.ts b/render-markdown-codehighlight/hooks.ts
index 1cec680..3ccbeb4 100644
--- a/render-markdown-codehighlight/hooks.ts
+++ b/render-markdown-codehighlight/hooks.ts
@@ -17,19 +17,21 @@
  * under the License.
  */
 
-import { useEffect, useState } from 'react';
+import { useEffect, useState, FC } from 'react';
 import hljs from 'highlight.js';
 import { themeStyles } from './themeStyles';
+import { pluginHookProps, Request } from './types';
 
-
-const useHighlightCode = (props: HTMLElement | null | {
+const useHighlightCode: FC<pluginHookProps> = (props: HTMLElement | null | {
   current: HTMLElement | null;
+}, request: Request = {
+  get: fetch,
 }) => {
   const [selectTheme, setSelectTheme] = useState<string>('default');
 
   // Fetch theme from API
   useEffect(() => {
-    fetch('/answer/api/v1/render/config')
+    request.get('/answer/api/v1/render/config')
       .then((response) => response.json())
       .then((result) => {
         console.log('Fetched theme:', result.data.select_theme);
diff --git a/render-markdown-codehighlight/types.ts b/render-markdown-codehighlight/types.ts
new file mode 100644
index 0000000..ad5aebd
--- /dev/null
+++ b/render-markdown-codehighlight/types.ts
@@ -0,0 +1,7 @@
+import { RefObject } from 'react';
+
+export type pluginHookProps = HTMLElement | RefObject<HTMLElement> | null;
+
+export interface Request {
+    get: (url: string) => Promise<Response>;
+}


(incubator-answer-plugins) 01/04: refactor(embed-basic): Update useRenderEmbed hook to accept a request object

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 277b7434cd005e03d9b3d14df31e9e43686f4c69
Author: robin <ro...@rnode.me>
AuthorDate: Wed Sep 25 16:40:41 2024 +0800

    refactor(embed-basic): Update useRenderEmbed hook to accept a request object
---
 embed-basic/hooks.tsx | 11 ++++++-----
 embed-basic/types.ts  |  7 +++++++
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/embed-basic/hooks.tsx b/embed-basic/hooks.tsx
index be023dd..c5e48c1 100644
--- a/embed-basic/hooks.tsx
+++ b/embed-basic/hooks.tsx
@@ -20,9 +20,9 @@
 import {
   useEffect,
   useState,
-  RefObject,
   ReactElement,
   isValidElement,
+  FC,
 } from 'react';
 import { createRoot } from 'react-dom/client';
 import {
@@ -36,15 +36,16 @@ import {
   DropboxEmbed,
   TwitterEmbed,
 } from './components';
+import { pluginHookProps, Request } from './types';
 
 interface Config {
   platform: string;
   enable: boolean;
 }
 
-const useRenderEmbed = (
-  element: HTMLElement | RefObject<HTMLElement> | null,
-) => {
+const useRenderEmbed : FC<pluginHookProps> = (element, request: Request = {
+  get: fetch,
+})=> {
   const [configs, setConfigs] = useState<Config[] | null>(null);
 
   const embeds = [
@@ -247,7 +248,7 @@ const useRenderEmbed = (
   };
 
   const getConfig = () => {
-    fetch('/answer/api/v1/embed/config')
+    request.get('/answer/api/v1/embed/config')
       .then((response) => response.json())
       .then((result) => setConfigs(result.data));
   };
diff --git a/embed-basic/types.ts b/embed-basic/types.ts
new file mode 100644
index 0000000..ad5aebd
--- /dev/null
+++ b/embed-basic/types.ts
@@ -0,0 +1,7 @@
+import { RefObject } from 'react';
+
+export type pluginHookProps = HTMLElement | RefObject<HTMLElement> | null;
+
+export interface Request {
+    get: (url: string) => Promise<Response>;
+}


(incubator-answer-plugins) 04/04: chore: Update version in info.yaml files

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 b9b677f80021d4aa136bd7050f5527520cf9e52d
Author: robin <ro...@rnode.me>
AuthorDate: Wed Sep 25 16:45:25 2024 +0800

    chore: Update version in info.yaml files
---
 embed-basic/info.yaml                   | 2 +-
 render-markdown-codehighlight/info.yaml | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/embed-basic/info.yaml b/embed-basic/info.yaml
index 054f43a..2c69f65 100644
--- a/embed-basic/info.yaml
+++ b/embed-basic/info.yaml
@@ -17,6 +17,6 @@
 
 slug_name: basic_embed
 type: editor
-version: 1.0.5
+version: 1.1.0
 author: answerdev
 link: https://github.com/apache/incubator-answer-plugins/tree/main/embed-basic
diff --git a/render-markdown-codehighlight/info.yaml b/render-markdown-codehighlight/info.yaml
index b6fa9a9..2ad8ed2 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.4
+version: 0.1.0
 author: Chen Jiaji, Zhu Xuanlyu
 link: https://github.com/apache/incubator-answer-plugins/tree/main/render-markdown-codehighlight


(incubator-answer-plugins) 03/04: refactor: Code to add Apache License header

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 5a554354d7b55e5b5a145fcfd82350f51635d81e
Author: robin <ro...@rnode.me>
AuthorDate: Wed Sep 25 16:42:46 2024 +0800

    refactor: Code to add Apache License header
---
 embed-basic/types.ts                   | 19 +++++++++++++++++++
 render-markdown-codehighlight/types.ts | 19 +++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/embed-basic/types.ts b/embed-basic/types.ts
index ad5aebd..6a034fc 100644
--- a/embed-basic/types.ts
+++ b/embed-basic/types.ts
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import { RefObject } from 'react';
 
 export type pluginHookProps = HTMLElement | RefObject<HTMLElement> | null;
diff --git a/render-markdown-codehighlight/types.ts b/render-markdown-codehighlight/types.ts
index ad5aebd..6a034fc 100644
--- a/render-markdown-codehighlight/types.ts
+++ b/render-markdown-codehighlight/types.ts
@@ -1,3 +1,22 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
 import { RefObject } from 'react';
 
 export type pluginHookProps = HTMLElement | RefObject<HTMLElement> | null;