fix markdown props

This commit is contained in:
JzoNg 2025-11-17 14:56:45 +08:00
parent 87f6ac78c5
commit 8f2660cea8
8 changed files with 49 additions and 5 deletions

View File

@ -18,7 +18,7 @@ export type MarkdownProps = {
content: string
className?: string
pluginInfo?: SimplePluginInfo
} & Pick<ReactMarkdownWrapperProps, 'customComponents' | 'customDisallowedElements'>
} & Pick<ReactMarkdownWrapperProps, 'customComponents' | 'customDisallowedElements' | 'rehypePlugins'>
export const Markdown = (props: MarkdownProps) => {
const { customComponents = {}, pluginInfo } = props

View File

@ -22,6 +22,7 @@ export type ReactMarkdownWrapperProps = {
customDisallowedElements?: string[]
customComponents?: Record<string, React.ComponentType<any>>
pluginInfo?: SimplePluginInfo
rehypePlugins?: any// js: PluggableList[]
}
export const ReactMarkdownWrapper: FC<ReactMarkdownWrapperProps> = (props) => {
@ -55,6 +56,7 @@ export const ReactMarkdownWrapper: FC<ReactMarkdownWrapperProps> = (props) => {
tree.children.forEach(iterate)
}
},
...(props.rehypePlugins || []),
]}
urlTransform={customUrlTransform}
disallowedElements={['iframe', 'head', 'html', 'meta', 'link', 'style', 'body', ...(props.customDisallowedElements || [])]}

View File

@ -6,7 +6,7 @@ import { produce } from 'immer'
import { useWorkflowStore } from '@/app/components/workflow/store'
import type { HumanInputRequiredResponse } from '@/types/workflow'
import { NodeRunningStatus } from '@/app/components/workflow/types'
import { WorkflowRunningStatus } from '@/app/components/workflow/types'
// import { WorkflowRunningStatus } from '@/app/components/workflow/types'
export const useWorkflowNodeHumanInputRequired = () => {
const workflowStore = useWorkflowStore()
@ -27,13 +27,15 @@ export const useWorkflowNodeHumanInputRequired = () => {
const newNodes = produce(nodes, (draft) => {
draft[currentNodeIndex].data._runningStatus = NodeRunningStatus.Suspended
// draft[currentNodeIndex].data._waitingRun = false
// store form data & input form schema
})
setNodes(newNodes)
// cache form data & generate input form UI in node data
setWorkflowRunningData(produce(workflowRunningData!, (draft) => {
draft.result = {
...draft.result,
status: WorkflowRunningStatus.Suspended,
// status: WorkflowRunningStatus.Suspended, // human input required !== workflow 'Suspended'
}
}))
}, [workflowStore])

View File

@ -71,6 +71,7 @@ type Props = {
availableVars?: NodeOutPutVar[]
isAddBtnTrigger?: boolean
trigger?: React.ReactNode
isJustShowValue?: boolean
schema?: Partial<CredentialFormSchema>
valueTypePlaceHolder?: string
isInTable?: boolean
@ -104,6 +105,7 @@ const VarReferencePicker: FC<Props> = ({
availableNodes: passedInAvailableNodes,
availableVars: passedInAvailableVars,
trigger,
isJustShowValue,
isAddBtnTrigger,
schema,
valueTypePlaceHolder,
@ -432,7 +434,7 @@ const VarReferencePicker: FC<Props> = ({
<AddButton onClick={noop}></AddButton>
</div>
)
: (<div ref={!isSupportConstantValue ? triggerRef : null} className={cn((open || isFocus) ? 'border-gray-300' : 'border-gray-100', 'group/wrap relative flex h-8 w-full items-center', !isSupportConstantValue && 'rounded-lg bg-components-input-bg-normal p-1', isInTable && 'border-none bg-transparent', readonly && 'bg-components-input-bg-disabled')}>
: (<div ref={!isSupportConstantValue ? triggerRef : null} className={cn((open || isFocus) ? 'border-gray-300' : 'border-gray-100', 'group/wrap relative flex h-8 w-full items-center', !isSupportConstantValue && 'rounded-lg bg-components-input-bg-normal p-1', isInTable && 'border-none bg-transparent', readonly && 'bg-components-input-bg-disabled', isJustShowValue && 'h-6 bg-transparent p-0')}>
{isSupportConstantValue
? <div onClick={(e) => {
e.stopPropagation()
@ -544,7 +546,7 @@ const VarReferencePicker: FC<Props> = ({
</VarPickerWrap>
)}
{(hasValue && !readonly && !isInTable) && (<div
{(hasValue && !readonly && !isInTable && !isJustShowValue) && (<div
className='group invisible absolute right-1 top-[50%] h-5 translate-y-[-50%] cursor-pointer rounded-md p-1 hover:bg-state-base-hover group-hover/wrap:visible'
onClick={handleClearVar}
>

View File

@ -18,10 +18,12 @@ const nodeDefault: NodeDefault<HumanInputNodeType> = {
defaultValue: {
delivery_methods: [
{
id: 'webapp-method',
type: DeliveryMethodType.WebApp,
enabled: true,
},
{
id: 'email-method',
type: DeliveryMethodType.Email,
enabled: false,
},

View File

@ -0,0 +1,33 @@
import { memo } from 'react'
// import { useStore } from '../store'
import BlockIcon from '@/app/components/workflow/block-icon'
import { BlockEnum } from '../types'
type props = {
nodeID: string
nodeTitle: string
formData: any
}
const HumanInputInfo = ({ nodeTitle }: props) => {
// const historyWorkflowData = useStore(s => s.historyWorkflowData)
return (
<div className='rounded-2xl border-[0.5px] border-components-panel-border bg-components-panel-bg p-2 shadow-xs'>
<div className='p-2'>
{/* node icon */}
<BlockIcon
type={BlockEnum.HumanInput}
// toolIcon={triggerIcon}
/>
{/* node name */}
<div className='system-sm-semibold-uppercase text-text-primary'>{nodeTitle}</div>
</div>
<div>
{/* human input form content */}
</div>
</div>
)
}
export default memo(HumanInputInfo)

View File

@ -167,6 +167,7 @@ const WorkflowPreview = () => {
)}
{currentTab === 'RESULT' && (
<>
{/* human input form position */}
<ResultText
isRunning={workflowRunningData?.result?.status === WorkflowRunningStatus.Running || !workflowRunningData?.result}
outputs={workflowRunningData?.resultText}

View File

@ -9,6 +9,8 @@ import type { FileUploadConfigResponse } from '@/models/common'
type PreviewRunningData = WorkflowRunningData & {
resultTabActive?: boolean
resultText?: string
// human input form schema or data cached when node is in 'Suspended' status
extraContentAndFormData?: Record<string, any>
}
export type WorkflowSliceShape = {