mirror of
https://github.com/whyour/qinglong.git
synced 2025-12-13 07:25:05 +08:00
Comprehensive fixes based on feedback: 1. Fixed zoom: use playgroundTools.zoom for reading, playgroundTools.config.updateZoom for setting 2. Created useAddNode hook following Flowgram pattern for proper node addition 3. Added Minimap component to DemoTools (removed from useEditorProps plugin) 4. Fixed createHistoryNodePlugin to accept opts parameter 5. Updated createPanelManagerPlugin to create custom tools panel 6. Created NodePanel component following Flowgram demo pattern 7. Updated createFreeNodePanelPlugin with renderer parameter 8. All components now follow official Flowgram.ai patterns exactly Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import { useMemo } from 'react';
|
|
import { FreeLayoutProps } from '@flowgram.ai/free-layout-editor';
|
|
import { createFreeSnapPlugin } from '@flowgram.ai/free-snap-plugin';
|
|
import { createFreeLinesPlugin } from '@flowgram.ai/free-lines-plugin';
|
|
import { createFreeNodePanelPlugin } from '@flowgram.ai/free-node-panel-plugin';
|
|
import { createPanelManagerPlugin } from '@flowgram.ai/panel-manager-plugin';
|
|
import { createHistoryNodePlugin } from '@flowgram.ai/history-node-plugin';
|
|
import { FlowNodeRegistry } from '../nodes/http';
|
|
import { createToolsPlugin } from '../plugins/tools-plugin';
|
|
import { NodePanel } from '../components/node-panel';
|
|
|
|
export function useEditorProps(
|
|
initialData: any,
|
|
nodeRegistries: FlowNodeRegistry[]
|
|
): FreeLayoutProps {
|
|
return useMemo<FreeLayoutProps>(
|
|
() => ({
|
|
background: true,
|
|
playground: {
|
|
preventGlobalGesture: true,
|
|
},
|
|
readonly: false,
|
|
twoWayConnection: true,
|
|
initialData,
|
|
nodeRegistries,
|
|
plugins: () => [
|
|
createFreeSnapPlugin({}),
|
|
createFreeLinesPlugin({}),
|
|
createFreeNodePanelPlugin({
|
|
renderer: NodePanel,
|
|
}),
|
|
createHistoryNodePlugin({}),
|
|
createPanelManagerPlugin({
|
|
factories: [],
|
|
layerProps: {},
|
|
}),
|
|
createToolsPlugin(),
|
|
],
|
|
onChange: (data) => {
|
|
console.log('Workflow changed:', data);
|
|
},
|
|
}),
|
|
[initialData, nodeRegistries]
|
|
);
|
|
}
|