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