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

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

commit 565ee3cc1b49ed0f836ba6fc1eef9b028abaab49
Author: shuai <[email protected]>
AuthorDate: Tue Dec 3 10:18:18 2024 +0800

    fix: Attachment accept type adjustment, editor plug-in insertion position 
added conditional restrictions
---
 ui/src/components/Editor/ToolBars/file.tsx | 4 +++-
 ui/src/components/PluginRender/index.tsx   | 8 +++++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ui/src/components/Editor/ToolBars/file.tsx 
b/ui/src/components/Editor/ToolBars/file.tsx
index 15238379..9e6e7399 100644
--- a/ui/src/components/Editor/ToolBars/file.tsx
+++ b/ui/src/components/Editor/ToolBars/file.tsx
@@ -122,7 +122,9 @@ const Image = ({ editorInstance }) => {
       <input
         type="file"
         className="d-none"
-        
accept={authorized_attachment_extensions.join(',.').toLocaleLowerCase()}
+        accept={`.${authorized_attachment_extensions
+          .join(',.')
+          .toLocaleLowerCase()}`}
         ref={fileInputRef}
         onChange={onUpload}
       />
diff --git a/ui/src/components/PluginRender/index.tsx 
b/ui/src/components/PluginRender/index.tsx
index 9de283f5..002d5a58 100644
--- a/ui/src/components/PluginRender/index.tsx
+++ b/ui/src/components/PluginRender/index.tsx
@@ -20,6 +20,7 @@
 import React, { FC, ReactNode } from 'react';
 
 import PluginKit, { Plugin, PluginType } from '@/utils/pluginKit';
+import { writeSettingStore } from '@/stores';
 /**
  * Note:Please set at least either of the `slug_name` and `type` attributes, 
otherwise no plugins will be rendered.
  *
@@ -47,6 +48,9 @@ const Index: FC<Props> = ({
 }) => {
   const pluginSlice: Plugin[] = [];
   const plugins = PluginKit.getPlugins().filter((plugin) => plugin.activated);
+  const { authorized_attachment_extensions = [] } = writeSettingStore(
+    (state) => state.write,
+  );
 
   plugins.forEach((plugin) => {
     if (type && slug_name) {
@@ -76,8 +80,10 @@ const Index: FC<Props> = ({
   }
 
   if (type === 'editor') {
+    const showAttachFile = authorized_attachment_extensions?.length > 0;
+    const pendIndex = showAttachFile ? 16 : 15;
     const nodes = React.Children.map(children, (child, index) => {
-      if (index === 15) {
+      if (index === pendIndex) {
         return (
           <>
             {child}

Reply via email to