MCPcopy Index your code
hub / github.com/FlowiseAI/Flowise / RichInput

Function RichInput

packages/ui/src/ui-component/input/RichInput.jsx:109–184  ·  view source on GitHub ↗
({ inputParam, value, nodes, edges, nodeId, onChange, disabled = false })

Source from the content-addressed store, hash-verified

107}))
108
109export const RichInput = ({ inputParam, value, nodes, edges, nodeId, onChange, disabled = false }) => {
110 const useMarkdown = !!inputParam?.rows
111 const customization = useSelector((state) => state.customization)
112 const isDarkMode = customization.isDarkMode
113 const [availableNodesForVariable, setAvailableNodesForVariable] = useState([])
114 const [availableState, setAvailableState] = useState([])
115 const [nodeData, setNodeData] = useState({})
116 const [isNodeInsideInteration, setIsNodeInsideInteration] = useState(false)
117
118 useEffect(() => {
119 if (!disabled && nodes && edges && nodeId && inputParam) {
120 const nodesForVariable = inputParam?.acceptVariable ? getAvailableNodesForVariable(nodes, edges, nodeId, inputParam.id) : []
121 setAvailableNodesForVariable(nodesForVariable)
122
123 const startAgentflowNode = nodes.find((node) => node.data.name === 'startAgentflow')
124 const state = startAgentflowNode?.data?.inputs?.startState
125 setAvailableState(state)
126
127 const agentflowNode = nodes.find((node) => node.data.id === nodeId)
128 setNodeData(agentflowNode?.data)
129
130 setIsNodeInsideInteration(nodes.find((node) => node.data.id === nodeId)?.extent === 'parent')
131 }
132 }, [disabled, inputParam, nodes, edges, nodeId])
133
134 const editor = useEditor(
135 {
136 extensions: [
137 ...extensions(
138 availableNodesForVariable,
139 availableState,
140 inputParam?.acceptNodeOutputAsVariable,
141 nodes,
142 nodeData,
143 isNodeInsideInteration,
144 useMarkdown
145 ),
146 Placeholder.configure({ placeholder: inputParam?.placeholder })
147 ],
148 content: '',
149 onUpdate: ({ editor }) => {
150 if (useMarkdown) {
151 try {
152 onChange(unescapeXmlTags(editor.getMarkdown()))
153 } catch {
154 onChange(editor.getHTML())
155 }
156 } else {
157 onChange(editor.getHTML())
158 }
159 },
160 editable: !disabled
161 },
162 [availableNodesForVariable]
163 )
164
165 // Load initial content after editor is ready, detecting HTML vs markdown
166 useEffect(() => {

Callers

nothing calls this directly

Calls 8

useEditorFunction · 0.90
unescapeXmlTagsFunction · 0.90
isHtmlContentFunction · 0.90
escapeXmlTagsFunction · 0.90
unescapeXmlEntitiesFunction · 0.90
extensionsFunction · 0.70
onChangeFunction · 0.50

Tested by

no test coverage detected