feat(web): workflow support lexical editor
This commit is contained in:
@@ -99,14 +99,14 @@ const AutocompletePlugin: FC<{ suggestions: Suggestion[] }> = ({ suggestions })
|
||||
|
||||
if (!showSuggestions) return null;
|
||||
|
||||
// Group suggestions by node name
|
||||
// Group suggestions by node id
|
||||
const groupedSuggestions = suggestions.reduce((groups: Record<string, any[]>, suggestion) => {
|
||||
const { nodeData } = suggestion
|
||||
const nodeName = (nodeData.name || nodeData.id) as string;
|
||||
if (!groups[nodeName]) {
|
||||
groups[nodeName] = [];
|
||||
const nodeId = nodeData.id as string;
|
||||
if (!groups[nodeId]) {
|
||||
groups[nodeId] = [];
|
||||
}
|
||||
groups[nodeName].push(suggestion);
|
||||
groups[nodeId].push(suggestion);
|
||||
return groups;
|
||||
}, {});
|
||||
|
||||
@@ -127,8 +127,10 @@ const AutocompletePlugin: FC<{ suggestions: Suggestion[] }> = ({ suggestions })
|
||||
transform: 'translateY(-100%)',
|
||||
}}
|
||||
>
|
||||
{Object.entries(groupedSuggestions).map(([nodeName, nodeOptions], groupIndex) => (
|
||||
<div key={nodeName}>
|
||||
{Object.entries(groupedSuggestions).map(([nodeId, nodeOptions], groupIndex) => {
|
||||
const nodeName = nodeOptions[0]?.nodeData?.name || nodeId;
|
||||
return (
|
||||
<div key={nodeId}>
|
||||
{groupIndex > 0 && <div style={{ height: '1px', background: '#f0f0f0', margin: '4px 0' }} />}
|
||||
<div style={{ padding: '4px 12px', fontSize: '12px', color: '#999', fontWeight: 'bold' }}>
|
||||
{nodeName}
|
||||
@@ -176,7 +178,8 @@ const AutocompletePlugin: FC<{ suggestions: Suggestion[] }> = ({ suggestions })
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
))}
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,12 @@ const Properties: FC<PropertiesProps> = ({
|
||||
const [editIndex, setEditIndex] = useState<number | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
form.resetFields()
|
||||
if (selectedNode?.getData().id) {
|
||||
form.resetFields()
|
||||
}
|
||||
}, [selectedNode?.getData().id])
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedNode && form) {
|
||||
const { type = 'default', name = '', config } = selectedNode.getData() || {}
|
||||
const initialValue: Record<string, any> = {}
|
||||
@@ -61,11 +66,9 @@ const Properties: FC<PropertiesProps> = ({
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
console.log('values', values)
|
||||
if (values && selectedNode) {
|
||||
const { id, ...rest } = values
|
||||
|
||||
|
||||
Object.keys(values).forEach(key => {
|
||||
if (selectedNode.data?.config[key]) {
|
||||
selectedNode.data.config[key].defaultValue = values[key]
|
||||
|
||||
Reference in New Issue
Block a user