Skip to content

Commit

Permalink
fix: Attachment accept type adjustment, editor plug-in insertion posi…
Browse files Browse the repository at this point in the history
…tion added conditional restrictions
  • Loading branch information
shuashuai committed Dec 3, 2024
1 parent a63078e commit 2770ffa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion ui/src/components/Editor/ToolBars/file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
Expand Down
8 changes: 7 additions & 1 deletion ui/src/components/PluginRender/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 2770ffa

Please sign in to comment.