mirror of
https://github.com/labring/FastGPT.git
synced 2026-04-27 02:08:10 +08:00
fix: workflow batch repeat run (#6186)
* stop design doc * remove invalid doc * perf: auto fit * fix: icon * perf: icon * perf: icon * perf: icon * perf: icon * perf: variable disabled input ui * fix: workflow batch run * fix: tsc
This commit is contained in:
@@ -43,6 +43,7 @@ import MarkdownPlugin from './plugins/MarkdownPlugin';
|
||||
import MyIcon from '../../Icon';
|
||||
import ListExitPlugin from './plugins/ListExitPlugin';
|
||||
import KeyDownPlugin from './plugins/KeyDownPlugin';
|
||||
import EditablePlugin from './plugins/EditablePlugin';
|
||||
|
||||
const Placeholder = ({ children, padding }: { children: React.ReactNode; padding: string }) => (
|
||||
<Box
|
||||
@@ -80,6 +81,7 @@ export type EditorProps = {
|
||||
placeholder?: string;
|
||||
placeholderPadding?: string;
|
||||
isInvalid?: boolean;
|
||||
isDisabled?: boolean;
|
||||
onKeyDown?: (e: React.KeyboardEvent) => void;
|
||||
ExtensionPopover?: ((e: {
|
||||
onChangeText: (text: string) => void;
|
||||
@@ -105,6 +107,7 @@ export default function Editor({
|
||||
placeholderPadding = '12px 14px',
|
||||
bg = 'white',
|
||||
isInvalid,
|
||||
isDisabled = false,
|
||||
onKeyDown,
|
||||
ExtensionPopover,
|
||||
boxStyle
|
||||
@@ -179,7 +182,13 @@ export default function Editor({
|
||||
<RichTextPlugin
|
||||
contentEditable={
|
||||
<ContentEditable
|
||||
className={`${isInvalid ? styles.contentEditable_invalid : styles.contentEditable} ${styles.richText}`}
|
||||
className={`${
|
||||
isDisabled
|
||||
? styles.contentEditable_disabled
|
||||
: isInvalid
|
||||
? styles.contentEditable_invalid
|
||||
: styles.contentEditable
|
||||
} ${styles.richText}`}
|
||||
style={{
|
||||
minHeight: `${minH}px`,
|
||||
maxHeight: `${maxH}px`,
|
||||
@@ -194,7 +203,13 @@ export default function Editor({
|
||||
<PlainTextPlugin
|
||||
contentEditable={
|
||||
<ContentEditable
|
||||
className={isInvalid ? styles.contentEditable_invalid : styles.contentEditable}
|
||||
className={
|
||||
isDisabled
|
||||
? styles.contentEditable_disabled
|
||||
: isInvalid
|
||||
? styles.contentEditable_invalid
|
||||
: styles.contentEditable
|
||||
}
|
||||
style={{
|
||||
minHeight: `${minH}px`,
|
||||
maxHeight: `${maxH}px`,
|
||||
@@ -211,8 +226,9 @@ export default function Editor({
|
||||
<>
|
||||
<HistoryPlugin />
|
||||
<MaxLengthPlugin maxLength={maxLength || 999999} />
|
||||
<FocusPlugin focus={focus} setFocus={setFocus} />
|
||||
<FocusPlugin focus={focus} setFocus={setFocus} isDisabled={isDisabled} />
|
||||
<KeyDownPlugin onKeyDown={onKeyDown} />
|
||||
<EditablePlugin isDisabled={isDisabled || !onChangeText} />
|
||||
|
||||
{variableLabels.length > 0 && (
|
||||
<>
|
||||
|
||||
@@ -72,6 +72,29 @@
|
||||
box-shadow: 0px 0px 0px 2.4px rgba(244, 69, 46, 0.15);
|
||||
}
|
||||
|
||||
.contentEditable_disabled {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
border: 1px solid rgb(232, 235, 240);
|
||||
border-radius: var(--chakra-radii-sm);
|
||||
padding: 8px 12px;
|
||||
|
||||
font-size: var(--chakra-fontSizes-sm);
|
||||
overflow-y: auto;
|
||||
|
||||
&::-webkit-scrollbar {
|
||||
color: var(--chakra-colors-myGray-100);
|
||||
}
|
||||
&::-webkit-scrollbar-thumb {
|
||||
background-color: var(--chakra-colors-myGray-200) !important;
|
||||
cursor: pointer;
|
||||
}
|
||||
&::-webkit-scrollbar-thumb:hover {
|
||||
background-color: var(--chakra-colors-myGray-250) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.variable {
|
||||
color: var(--chakra-colors-primary-600);
|
||||
padding: 0 2px;
|
||||
|
||||
@@ -68,6 +68,7 @@ const PromptEditor = ({
|
||||
onChangeText={onChange}
|
||||
onBlur={onBlurInput}
|
||||
onKeyDown={onKeyDown}
|
||||
isDisabled={isDisabled}
|
||||
/>
|
||||
{isDisabled && (
|
||||
<Box
|
||||
@@ -76,10 +77,11 @@ const PromptEditor = ({
|
||||
left={0}
|
||||
right={0}
|
||||
bottom={0}
|
||||
bg="rgba(255, 255, 255, 0.4)"
|
||||
bg="rgba(255, 255, 255, 0.5)"
|
||||
borderRadius="md"
|
||||
zIndex={1}
|
||||
cursor="not-allowed"
|
||||
pointerEvents="none"
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
@@ -92,17 +94,34 @@ const PromptEditor = ({
|
||||
w={'full'}
|
||||
>
|
||||
<ModalBody>
|
||||
<Editor
|
||||
{...props}
|
||||
minH={400}
|
||||
maxH={400}
|
||||
showOpenModal={false}
|
||||
value={formattedValue}
|
||||
onChange={onChangeInput}
|
||||
onChangeText={onChange}
|
||||
onBlur={onBlurInput}
|
||||
onKeyDown={onKeyDown}
|
||||
/>
|
||||
<Box position="relative">
|
||||
<Editor
|
||||
{...props}
|
||||
minH={400}
|
||||
maxH={400}
|
||||
showOpenModal={false}
|
||||
value={formattedValue}
|
||||
onChange={onChangeInput}
|
||||
onChangeText={onChange}
|
||||
onBlur={onBlurInput}
|
||||
onKeyDown={onKeyDown}
|
||||
isDisabled={isDisabled}
|
||||
/>
|
||||
{isDisabled && (
|
||||
<Box
|
||||
position="absolute"
|
||||
top={0}
|
||||
left={0}
|
||||
right={0}
|
||||
bottom={0}
|
||||
bg="rgba(255, 255, 255, 0.5)"
|
||||
borderRadius="md"
|
||||
zIndex={1}
|
||||
cursor="not-allowed"
|
||||
pointerEvents="none"
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button mr={2} onClick={onClose} px={6}>
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
export default function EditablePlugin({ isDisabled }: { isDisabled: boolean }) {
|
||||
const [editor] = useLexicalComposerContext();
|
||||
|
||||
useEffect(() => {
|
||||
editor.setEditable(!isDisabled);
|
||||
}, [editor, isDisabled]);
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -2,7 +2,15 @@ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext
|
||||
import { useEffect } from 'react';
|
||||
import { BLUR_COMMAND, COMMAND_PRIORITY_LOW, FOCUS_COMMAND } from 'lexical';
|
||||
|
||||
export default function FocusPlugin({ focus, setFocus }: { focus: Boolean; setFocus: any }) {
|
||||
export default function FocusPlugin({
|
||||
focus,
|
||||
setFocus,
|
||||
isDisabled
|
||||
}: {
|
||||
focus: Boolean;
|
||||
setFocus: any;
|
||||
isDisabled?: boolean;
|
||||
}) {
|
||||
const [editor] = useLexicalComposerContext();
|
||||
|
||||
useEffect(
|
||||
@@ -10,12 +18,14 @@ export default function FocusPlugin({ focus, setFocus }: { focus: Boolean; setFo
|
||||
editor.registerCommand(
|
||||
BLUR_COMMAND,
|
||||
() => {
|
||||
setFocus(false);
|
||||
if (!isDisabled) {
|
||||
setFocus(false);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
COMMAND_PRIORITY_LOW
|
||||
),
|
||||
[]
|
||||
[isDisabled]
|
||||
);
|
||||
|
||||
useEffect(
|
||||
@@ -23,12 +33,14 @@ export default function FocusPlugin({ focus, setFocus }: { focus: Boolean; setFo
|
||||
editor.registerCommand(
|
||||
FOCUS_COMMAND,
|
||||
() => {
|
||||
setFocus(true);
|
||||
if (!isDisabled) {
|
||||
setFocus(true);
|
||||
}
|
||||
return false;
|
||||
},
|
||||
COMMAND_PRIORITY_LOW
|
||||
),
|
||||
[]
|
||||
[isDisabled]
|
||||
);
|
||||
|
||||
// useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user