mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 02:12:38 +00:00
fix: editor focus & picker highlight & ui (#2166)
* fix ui * fix editor focus & picker highlight
This commit is contained in:
@@ -20,18 +20,15 @@ export default function VariableLabelPlugin({
|
||||
throw new Error('VariableLabelPlugin: VariableLabelPlugin not registered on editor');
|
||||
}, [editor]);
|
||||
|
||||
const createVariableLabelPlugin = useCallback(
|
||||
(textNode: TextNode): VariableLabelNode => {
|
||||
const [parentKey, childrenKey] = textNode.getTextContent().slice(3, -3).split('.');
|
||||
const currentVariable = variables.find(
|
||||
(item) => item.parent?.id === parentKey && item.key === childrenKey
|
||||
);
|
||||
const variableLabel = `${currentVariable && currentVariable.parent?.label}.${currentVariable?.label}`;
|
||||
const nodeAvatar = currentVariable?.parent?.avatar || '';
|
||||
return $createVariableLabelNode(textNode.getTextContent(), variableLabel, nodeAvatar);
|
||||
},
|
||||
[variables]
|
||||
);
|
||||
const createVariableLabelPlugin = useCallback((textNode: TextNode): VariableLabelNode => {
|
||||
const [parentKey, childrenKey] = textNode.getTextContent().slice(3, -3).split('.');
|
||||
const currentVariable = variables.find(
|
||||
(item) => item.parent.id === parentKey && item.key === childrenKey
|
||||
);
|
||||
const variableLabel = `${currentVariable && currentVariable.parent?.label}.${currentVariable?.label}`;
|
||||
const nodeAvatar = currentVariable?.parent?.avatar || '';
|
||||
return $createVariableLabelNode(textNode.getTextContent(), variableLabel, nodeAvatar);
|
||||
}, []);
|
||||
|
||||
const getVariableMatch = useCallback((text: string) => {
|
||||
const matches = REGEX.exec(text);
|
||||
@@ -55,7 +52,7 @@ export default function VariableLabelPlugin({
|
||||
createVariableLabelPlugin
|
||||
)
|
||||
);
|
||||
}, [createVariableLabelPlugin, editor, getVariableMatch, variables]);
|
||||
}, [createVariableLabelPlugin, editor, getVariableMatch]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
Reference in New Issue
Block a user